Zend Form: Checkbox element displays as hidden field?

后端 未结 6 1790
春和景丽
春和景丽 2021-02-20 08:34

I would like to add a simple check box to my form:

$element = new Zend_Form_Element_Checkbox(\'dont\');
$element->setDescription(\'Check this box if you don\\\         


        
6条回答
  •  天命终不由人
    2021-02-20 09:08

    topic is really old, but I found similar problem a few days ago - I create form dynamically, by javascript - clicking (+) adds a row (one hidden input, two checkboxes and two selects) to the displayed form.

    I found, when i send _POST to the server, that las row isn't sent corectly - default zeros from hidden are sent, instead of selected checkboxes. The solution, is to set checkboxes as arrays:

    $c = new Zend_Form_Element_Checkbox( 'check1' );
    $c->setIsArray( true );
    

    In this case, additional hidden input isn't rendered.

    PS. Sorry for my english ;)

提交回复
热议问题