How do I use ViewScripts on Zend_Form File Elements?

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

I am using this ViewScript for my standard form elements:

element->getId(); ?>\"> <
7条回答
  •  难免孤独
    2020-11-29 03:15

    The answer is relatively simple as it happens. All you need do is specify the File decorator first, create a specific view script for the file input and specify false for the placement in the viewScript decorator arguments, this will effectively inject the output from the File decorator into the viewScript decorator e.g.

    $element->setDecorators(array('File', array('ViewScript', array('viewScript' => 'decorators/file.phtml', 'placement' => false))));
    

    Then in the new file element view script you simply echo $this->content in the script where you'd like the file input markup to be placed. Here's an example from a recent project, so ignore the markup if it looks a little odd, hopefully it will illustrate the point.

    
    

    When rendered you will see this html for the element

    
    

提交回复
热议问题