zend form for multicheckbox remove input from labels

前端 未结 4 1072
一整个雨季
一整个雨季 2021-01-06 17:40

I am using zend_form (part of Zend Framwork) to create a form and found when I add a set of checkboxes using Zend_Form\'s multicheckbox element (Zend_Form_Element_MultiCheck

4条回答
  •  爱一瞬间的悲伤
    2021-01-06 18:17

    Here are some additionnal information about multiCheckBox rendering customization

    I wanted the checkboxes' labels to prepend instead of append (this default behaviour is hardcoded). As the ZF reference guide isn't talkative about it, I finally got into the core code to figure out how to customize it. Have a look to Zend_View_Helper_FormRadio::formRadio() for more info.

    It's possible to modify the checkboxes decorator via the multiCheckBox options : adding some options prefixed with label_.

    Here is my form element :

    $this->addElement('multiCheckbox', 'stars_number', array(
        'filters'         => array('Int'),
        'escape'          => false,        // to allow html in the labels
        'separator'       => '',           // to keep everything inline
        'label_placement' => 'prepend',
        'label_class'     => 'stars',      // custom css needed
        'decorators'      => $decorator_chain, // decorators array defined upper, and passed to many elements of the form
    ));
    

    I hope this will help some to save hours of unsuccessful google crawling...

提交回复
热议问题