Sunday, August 30, 2009

Re: How may I 'trick' $ajax->observeField into firing with linked combo boxes?

I think I solved my problem referenced on this thread. The solution
proposed with the array_unshift scrambled the data inside the
dropdown. The names were still sorted properly, but the id number with
that name got resequenced. Apparently that is what array_unshift does
for you, according to the docs.

So what I did, and I think it will work for me is I added this code to
the .ctp file that creates the dropdown list. Mine is called
ajax_dropdown.ctp because that is how it was in the tutorial I have
been using. Here is the code:

<?php $options = array('Pick me!') + $options; ?>
<?php foreach($options AS $k=>$v) : ?>
<option value="<?php echo $k; ?>"><?php echo $v; ?></option>
<?php endforeach; ?>

This successfully adds an element at the beginning of the dropdown
list 'Pick me!' (a reference to Donkey in Shrek...) and preserves the
elements beneath it.

I think I can move on to the next issue now...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: