Zend File Upload and Element Decorators

后端 未结 1 1905
一向
一向 2020-12-04 02:02

I have the problem, that the following Zend Form throws an error. The problem is the \"file\"-element and using setElementDecorators.

    class Products_AddF         


        
相关标签:
1条回答
  • 2020-12-04 02:53

    The File element requires it's own decorator - Zend_Form_Decorator_File.

    $this->setElementDecorators(array(
          'File',
          'Errors',
          array(array('data' => 'HtmlTag'), array('tag' => 'td')),
          array('Label', array('tag' => 'th')),
          array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
    ));
    

    [edit]

    Have just noticed that you are also using other form elements.

    After your original code, add:

    $this->getElement('Excel')->setDecorators(
        array(
            'File',
            'Errors',
            array(array('data' => 'HtmlTag'), array('tag' => 'td')),
            array('Label', array('tag' => 'th')),
            array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
        )
    );
    

    That way, ViewHelper is added to all other elements, and for your File element File is used instead.

    0 讨论(0)
提交回复
热议问题