Hi,
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) :
Display groups are a way to create
virtual groupings of elements for
display purposes. All elements remain
accessible by name in the form, but
when iterating over the form or
rendering, any elements in a display
group are rendered together. The most
common use case for this is for
grouping elements in fieldsets.
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 :
$form->addDisplayGroup(array('checkbox1', 'checkbox2', 'checkbox3'), 'firstgroup');
$form->addDisplayGroup(array('checkbox4', 'checkbox5', 'checkbox6'), 'fsecondgroup');
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 :
$form->addDisplayGroup(array(
'idCategory',
'date',
// ...
'tags',
'nbComments'
),
'postmeta',
array(
'order' => 2,
'attribs' => array(
'class' => 'group',
'legend' => 'Meta-données'
)
));
The "Meta-données", from what I recall, is the "legend
" used for the fieldset containing those elements.