php - Zend form multiselect repopulate after validation error -


I have a Zend Form Multisect Element that I'm making in this way

  $ This- & gt; Adelament ('Multisewall', 'Amadets', Array ('Filter' => Array ('StringTrim'), 'Required' = & gt; True, 'label' = & gt; 'Dates', 'Style' = & Gt; 'width: 14aam', 'size' => 4; 'register inrreadyator' = & gt; wrong, // otherwise it returns an error));  

Then I select multi-select multi option through JavaScript in multi-select (basically a UUI calendar where a user clicks on date and that is a multi-select form One option is available)

Everything is fine if I give all necessary values ​​and it is that they pass a Wild Test, if there is an error, then every other element whatever Is also presented but No multi-selection loses all this option and the user is reproduced on its own. Multi-selection seems to run fine because this is what I get if i get var dump $ this-> getRequest () - & gt; GetQuery (); This is what I get ["somedates"] = & gt; Array (2) {[0] = & gt; String (10) "2010-09-09" [1] = & gt; String (10) "2010-09-10"} I'm just thinking that someone has the same experience and knows what's going wrong here or if the ability of the Zend framework is the reconsideration of multi-select

The problem is that the ZF expects the user to select an option that you have zdf multislete when you add an option using Javascript, ZF does not know that this is now a valid option so verification fails. To get around this, you must have InArray validator

  $ this-> getElement ("somedates") -> RemoveDecorator ("In Array") is required to be removed;  

In order to popularize the array again, you need to save the user a few times, so if the form fails, then ZF can add them again. Can be combined with a hidden field, when the form is submitted, check this hidden fields for values ​​and add these dates back to MultiSelect input.

Make sure that you validate the input from the hidden fields, assuming that it does not have the correct date.


Comments