On Tue, Sep 7, 2010 at 12:57 AM, aveev <[email protected]> wrote: > It is because the options in dependent > select list is created with jquery when there is a change in another > select list (id=document) (I set onChange event to document select > list).
Then it's a jQuery problem, not CakePHP. Cake has nothing to do with setting the value in the first place, so why should it deal with re-setting it? > I can get the value of previously entered value for dependent select > list option in controller. > So my question is, how can I display options in dependent select list > with correctly selected value if validation fails ? > > What I'm thinking now is that I set a variable in controller when > validation fails. This variable will be passed to jquery.(this creates > another problem that I don't quite understand, which is passing > variable from controller to javascript/jquery) In jquery, we will > check if this variable is set. If it is, then create options for > dependent select list and select an option with previously selected > value. Otherwise create options with no selection. > Or maybe anyone has another ideas ?? > Thanks.. The simple way to pass a value from PHP to Javascript is to have the former write some javascript declaring the variable. But, in your case, the solution is simpler than that. On page load, have jQuery check the first list and then set the selected element of the 2nd list based on the first value. Just like it would do onchange. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
