Added by Wouter Geelen, last edited by Wouter Geelen on Aug 22, 2008

Labels

 

formSelectParent

Background

Well I for my blog a new Zend_View helper called formSelectParent. The reason for this is because I had a database called categories. And one category could be a child of another one. Well I wanted to use a select element (dropdown box). I first tried to use the the normal formSelect() function from Zend_Framework. But unfortunately you can only have 1 parent then since their can't be multiply optgroups into each other. Here is a visualization of what I wanted.

Well I then designed a helper called formSelectParent(). It has the same input as the formSelect() function but it will use it differently.

How to use

A example of the input

The output will be then:

The code

Maybe it will help some of you.