ZF-3882: InArray validator for nested arrays
Description
The current InArray implementation does not support nested arrays. Which makes it unusable for selects with optgroups (for example). Have such functionality will enable this functionality.
The current InArray implementation does not support nested arrays. Which makes it unusable for selects with optgroups (for example). Have such functionality will enable this functionality.
Comments
Posted by Brett Patterson (bpat1434) on 2008-08-14T13:20:28.000+0000
This is a huge downfall. It's creating a usability issue with my form. I can extend it; however, this should be a default feature. Is it too late to be added to 1.6? Perhaps for 1.6.1?
Posted by Brett Patterson (bpat1434) on 2008-08-14T19:43:12.000+0000
Just like to point out that I found two work-arounds for this. The first is the easiest and that is if you are retrieving valid items from a database, then whenever you iterate through to create the optgroup items, add the valid values to a new array and pass it in as a parameter to the InArray validator.
The other option is to override the InArray validator and add another method. I called it calculateValids() and here is it's construct:
Not the prettiest; however, it works :) Hopefully this can make it in to the next release or minor release.
Posted by Bart McLeod (mcleod@spaceweb.nl) on 2009-01-02T08:30:12.000+0000
I looked into the code of Zend_Form_Element_Multi, because I wanted to implement my own isValid method on a province select element. To my surprise, I found that validation of optgroups is supported. It works very well. The problem in my case was that I add added the multioptions in the render method, which is far to late for the validator to work (the validator will have no options at its disposal at all!).
After I implemented the getMultiOptions method to return a fixed set of provinces, validation worked just fine. So I wonder if this issue should not be marked as resolved?
Posted by Thomas Weidner (thomas) on 2009-06-27T09:22:02.000+0000
Under code review since 27.06.2009 (Incubator r16316)
Posted by Thomas Weidner (thomas) on 2009-09-29T14:28:13.000+0000
Feature implemented with ZF1.10. See option 'recursive'.