Zend Framework 2: Select Optgroups
Join the DZone community and get the full member experience.
Join For FreeOn my project I’m currently working on I needed to use optgroups. After looking high and low through the documentation and the code I discovered the feature kind of worked, but kind of didn’t. I issued a pull request that fixed the code for the next release (2.0.1) but here’s the skinny on how to set it up.
When setting the valueOptions attribute of a SelectElement specify an array as follows for optgroup support.
return array( array('label' => 'Jazz', 'options' => array( 'Acid', 'Cool', 'Smooth' ) ), array('label' => 'Rock', 'options' => array( 'Alternative Rock', 'Folk Rock', 'Garage Rock', 'Hard Rock', 'Heavy Metal' ) ) );
Published at DZone with permission of James Carr, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Trending
-
What Is Istio Service Mesh?
-
Avoiding Pitfalls With Java Optional: Common Mistakes and How To Fix Them [Video]
-
Auditing Tools for Kubernetes
-
Design Patterns for Microservices: Ambassador, Anti-Corruption Layer, and Backends for Frontends
Comments