0

I want to achieve the example html markup using Zend_Form_Element_Checkbox. Encounter problems, however, for example page_actions[]. I want to have this in a attribute and receive array in request. I know I must do it in the init of the form, but I lack knowledge of Zend Framework. I tried several options. For example, this:

// In for loop in init method
$element = new Zend_Form_Element_Checkbox('test['.$i.']');
$element->setIsArray(true)->setBelongsTo('checkbox_name');
$this->addElement($element);

This is the markup I would like to achieve:-

<div>
    <div>
        Some bold message for this group
    </div>
    <div>
        <span>
            <input type="checkbox" id="qf_18" value="12" name="page_actions[]"/><label for="qf_18">Test 18</label><br/>
            <input type="checkbox" id="qf_20" value="13" name="page_actions[]"/><label for="qf_20">Test 20</label><br/>
            <input type="checkbox" id="qf_22" value="14" name="page_actions[]"/><label for="qf_22">Test 22</label><br/>
            <input type="checkbox" id="qf_24" value="15" name="page_actions[]"/><label for="qf_24">Test 24</label><br/>
            <input type="checkbox" id="qf_26" value="16" name="page_actions[]"/><label for="qf_26">Test 26</label>
        </span>
    </div>
</div>
<div>
    <div style="font-weight: bold;">
        Some bold message for this other group
    </div>
    <div>
        <span>
            <input type="checkbox" id="qf_28" value="17" name="page_actions[]"/><label for="qf_28">Test 28</label><br/>
            <input type="checkbox" id="qf_30" value="18" name="page_actions[]"/><label for="qf_30">Test 30</label><br/>
            <input type="checkbox" id="qf_32" value="19" name="page_actions[]"/><label for="qf_32">Test 32</label><br/>
            <input type="checkbox" id="qf_34" value="20" name="page_actions[]"/><label for="qf_34">Test 34</label><br/>
            <input type="checkbox" id="qf_36" value="21" name="page_actions[]"/><label for="qf_36">Test 35</label>
        </span>
    </div>
</div>
vascowhite
  • 18,120
  • 9
  • 61
  • 77
Georgi Naumov
  • 4,160
  • 4
  • 40
  • 62
  • instead of providing too much code, please your PHP code and actual HTML output and expected HTML output – Raj Dec 28 '11 at 04:35
  • See this answer http://stackoverflow.com/a/8451723/212940 it will point you in the right direction. – vascowhite Dec 28 '11 at 09:06

1 Answers1

0

You can use view script to do that. I think zend form decorator is not support to this kind of form.

Dinuka Thilanga
  • 4,220
  • 10
  • 56
  • 93