How do I use ViewScripts on Zend_Form File Elements?

后端 未结 7 926
心在旅途
心在旅途 2020-11-29 02:43

I am using this ViewScript for my standard form elements:

element->getId(); ?>\"> <
7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-29 03:08

    This helped me fix my problem. I adjusted the code to wrap the file element inside a table. To make it work, simply remove the label from the viewdecorator and add the file element as follows:

    $form->addElement('file', 'upload_file', array(
            'disableLoadDefaultDecorators' => true,
            'decorators' => array(
                'Label',
                array(array('labelTd' => 'HtmlTag'), array('tag' => 'td', 'class' => 'labelElement')),
                array(array('elemTdOpen' => 'HtmlTag'), array('tag' => 'td', 'class' => 'dataElement','openOnly' => true, 'placement' => 'append')),
                'File',
                array('ViewScript', array(
                'viewScript' => 'decorators/file.phtml',
                'placement' => false,
                )),
                array(array('elemTdClose' => 'HtmlTag'), array('tag' => 'td', 'closeOnly' => true, 'placement' => 'append')),
                array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
            ),
            'label' => 'Upload',
            'required' => false,
            'filters' => array(),
            'validators' => array(array('Count', false, 1), ),
        ));
    

提交回复
热议问题