I need a zend_form which will contain mostly checkboxes. I need to group them and also display a title for each group. e.g.
Heading 1
Label1 Check1
Label2 Check2
Label3 Check3
Heading 2
Label4 Check4
Label5 Check5
Label6 Check6
First I don't know how to display the title ("headings")! Is there a way that you can add a label to a form bu not to an element or any other solution to add these titles in Zend Form?
Second how do I render this way? what kind of decorator should I use?
I red something about decorators but I did not understand much of it?
Anybody any Idea?
thanx!
Best Answer
You might be interested by this section of the manual, which seems to be exactly about what you want to obtain : 23.4.3. Display Groups (quoting) :
This should allow you to have your form elements re-grouped in fieldsets, and each one of those can have its legend -- in your case, that would be "heading X".
Once your checkboxes have been added to the form, you should be able to re-group them by using something like this :
For the rendering part, I suppose it'll use
Zend_Form_Decorator_Fieldset
Edit after the comment
To set the title of each group, you have to set its "
legend
", passing that as an option.For example, here is a piece of code I found from an old project I worked on quite some time ago :
The "Meta-données", from what I recall, is the "
legend
" used for the fieldset containing those elements.