0

フォームがあり、そのマークアップをカスタマイズしたいと考えています。クラスの一番下にあるデコレータを使用しています。ただし、エラーが発生し続けます:

フォームによってキャッチされた例外: ファイル デコレータが見つかりません。

誰かが私に例を示すことができるかどうか疑問に思っていました。私は基本的にフォームをそのまま出力し、標準のレイアウトを廃止したいと考えています。いくつかのカスタムクラスも追加するかもしれません。

更新しました

class Application_Form_Admin extends Zend_Form
{

    public function init()
    {
        // Set the method for the display form to POST
        $this->setMethod('post');

        // set the data format
        $this->setAttrib('enctype', 'multipart/form-data');

        // Add the entry id
        $this->addElement('hidden', 'id', array(
            'required'   => false
        ));

        // Add the title
        $this->addElement('text', 'title', array(
            'label'      => 'Project Title',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 60))
                )
        ));

        // Add the title
        $this->addElement('text', 'appid', array(
            'label'      => 'App Id',
            'required'   => true,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 60))
                )
        ));

        // Add the title
        $this->addElement('text', 'appsecret', array(
            'label'      => 'App Secret',
            'required'   => true,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 60))
                )
        ));

        // Add the title
        $this->addElement('text', 'namespace', array(
            'label'      => 'Namespace',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 60))
                )
        ));

        // Add the title
        $this->addElement('text', 'applink', array(
            'label'      => 'App Link',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 255))
                )
        ));

        // Facebook Only?
        $this->addElement('checkbox', 'fbonly', array(
            'label'      => 'Facebook Only',
            'required'   => false,
            'value'      => 1
        ));

        // general app data group
        $this->addDisplayGroup(array('title', 'appid', 'appsecret', 'namespace', 'applink', 'fbonly'), 'general', array('legend' => 'General Optons'));

        // Facebook Only?
        $this->addElement('checkbox', 'fangate', array(
            'label'      => 'Fangate Page',
            'required'   => false,
            'value'      => 1
        ));

        // Facebook Only?
        $this->addElement('checkbox', 'welcome', array(
            'label'      => 'Welcome Page',
            'required'   => false,
            'value'      => 1
        ));

        // Facebook Only?
        $this->addElement('checkbox', 'help', array(
            'label'      => 'Help Page',
            'required'   => false,
            'value'      => 1
        ));

        // Facebook Only?
        $this->addElement('checkbox', 'entries', array(
            'label'      => 'Entries Page',
            'required'   => false,
            'value'      => 1
        ));

        // pages enabled group
        $this->addDisplayGroup(array('fangate', 'welcome', 'help', 'entries'), 'page', array('legend' => 'Page Optons'));

        // Add the title
        $this->addElement('text', 'ogtype', array(
            'label'      => 'Default Open Graph Type',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 60))
                )
        ));

        // Add the title
        $this->addElement('text', 'ogtitle', array(
            'label'      => 'Default Open Graph Title',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 60))
                )
        ));

        // Add the title
        $this->addElement('text', 'ogdesc', array(
            'label'      => 'Default Open Graph Description',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 60))
                )
        ));

        // Add the title
        $this->addElement('file', 'ogimage', array(
            'label'      => 'Default App Image',
            'required'   => false
        ));

        // generic open graph data
        $this->addDisplayGroup(array('ogtype', 'ogtitle', 'ogdesc', 'ogimage'), 'og', array('legend' => 'Generic Open Graph data'));

        // Add the wall title
        $this->addElement('text', 'apptitle', array(
            'label'      => 'App Title',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 60))
                )
        ));

        // Add the wall caption
        $this->addElement('text', 'appcaption', array(
            'label'      => 'App Caption',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 60))
                )
        ));

        // Add the wall message
        $this->addElement('text', 'appdesc', array(
            'label'      => 'App Description',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 255))
                )
        ));

        // app message details
        $this->addDisplayGroup(array('apptitle', 'appcaption', 'appdesc'), 'appdetails', array('legend' => 'App deatils (Used when sharing)'));

        // Add the wall title
        $this->addElement('text', 'wallmsg', array(
            'label'      => 'Wall Message',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 255))
                )
        ));

        // Add the wall title
        $this->addElement('text', 'friendmsg', array(
            'label'      => 'Friends Wall Message',
            'required'   => false,
            'validators' => array(
                    array('validator' => 'StringLength', 'options' => array(0, 255))
                )
        ));

        // app message details
        $this->addDisplayGroup(array('wallmsg', 'friendmsg'), 'wallmessages', array('legend' => 'Wall post messages'));

        // Add the submit button
        $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Submit',
        ));

        // And finally add some CSRF protection
        $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));

        // change markup of elements
        $this->setElementDecorators(array(
            'ViewHelper',
            array(
                'Description',
                array(
                    'tag'    => 'div',
                    'class'  => 'submit-button',
                    'escape' => false
                )
            ),
            array(
                array(
                    'data' => 'HtmlTag'
                ),
                array(
                    'tag'   => 'span',
                    'class' => 'element'
                )
            ),
            array(
                'Label',
                array(
                    'tag'    => 'label',
                    'class' => 'elementLabel',
                    'escape' => false
                )
            ),
            'File',
            array(
                array(
                    'data' => 'HtmlTag'
                ),
                array(
                    'tag'   => 'span',
                    'class' => 'element'
                )
            ),
            array(
                array(
                    'row' => 'HtmlTag'
                ),
                array(
                    'tag'   => 'li',
                    'class' => 'element-row'
                ),
            ),
            'Errors'
        ));

        // change markup of form
        $this->setDecorators(array(
            'FormElements',
            array(
                'HtmlTag',
                array(
                    'tag' => 'div',
                    'id'  => $this->_containerId
                )
            ),
            'Form',
            'Errors'
        ));

    }


}
4

1 に答える 1

2

フォームに少なくとも1つの「File」要素があり、「File 」要素に必要なdecoratotrである「File」デコレータを呼び出しsetDecoratorsて含めませんでした。

35.6.4。Zend_Form_Element_File

ファイルフォーム要素は、ファイルアップロードフィールドをフォームに提供するためのメカニズムを提供します。Zend_File_Transferを内部的に利用してこの機能を提供し、FormFileビューヘルパーをファイルデコレータとして利用してフォーム要素を表示します。

于 2012-09-04T14:46:08.140 に答える