1
<?php

class Application_Form_Auth extends Zend_Form
{

    public function init() 
    {   $this->setAttrib('enctype', 'multipart/form-data');
        $this->setMethod('post');


        $username = $this->createElement('text','username');
        $username->setLabel('Username:')
                 ->setRequired(true);                               

        $username->setDecorators(array(



                   'ViewHelper',

                   'Description',

                   'Errors',

                   array(array('data'=>'HtmlTag'), array('tag' => 'td')),

                   array('Label', array('tag' => 'td')),

                   array(array('row'=>'HtmlTag'),array('tag'=>'tr'))



           ));


        $password=$this->createElement('password','password');
        $password->setLabel('Password')
                 ->setRequired(true);


                $password->setDecorators(array(



                   'ViewHelper',

                   'Description',

                   'Errors',

                   array(array('data'=>'HtmlTag'), array('tag' => 'td')),

                   array('Label', array('tag' => 'td')),

                   array(array('row'=>'HtmlTag'),array('tag'=>'tr'))



           ));




        $file = new Zend_Form_Element_File('file');

        $file->setLabel('File')

            ->setDestination(BASE_PATH . '/data/uploads')

            ->setRequired(true);

                    $file->setDecorators(array(



                   'file',

                   'Description',

                   'Errors',

                   array(array('data'=>'HtmlTag'), array('tag' => 'td')),

                   array('Label', array('tag' => 'td')),

                   array(array('row'=>'HtmlTag'),array('tag'=>'tr'))



           ));





$captcha = $this->createElement('captcha', 'captcha',
array('required' => true,
'captcha' => array(
'captcha' => 'Image',
'font' => BASE_PATH .'/fonts/Average-Regular.ttf',
'fontSize' => '24',
'wordLen' => 5,
'height' => '75',
'width' => '200',
'imgDir'=> BASE_PATH.'/images/captcha',
'imgUrl'=>'../../images/captcha/',
'dotNoiseLevel' => 50,
'lineNoiseLevel' => 5)));

$captcha->setLabel('Please type the words shown:');


                    $captcha->setDecorators(array(



                   'captcha',

                   'Description',

                   'Errors',

                   array(array('data'=>'HtmlTag'), array('tag' => 'td')),

                   array('Label', array('tag' => 'td')),

                   array(array('row'=>'HtmlTag'),array('tag'=>'tr'))



           ));

           $form = new ZendX_JQuery_Form();
$date1 = new ZendX_JQuery_Form_Element_DatePicker(
                        'date1',
                        array('label' => 'Date:')
        );


           $date1->setDecorators(array(


               'FormElements',


               'Description',

               'Errors', array(array('data'=>'HtmlTag'), array('tag' => 'td',

               'colspan'=>'2','align'=>'center')),

               array(array('row'=>'HtmlTag'),array('tag'=>'tr'))


       ));

        $reg=$this->createElement('submit','submit');
        $reg->setLabel('save'); 

            $reg->setDecorators(array(



               'ViewHelper',

               'Description',

               'Errors', array(array('data'=>'HtmlTag'), array('tag' => 'td',

               'colspan'=>'2','align'=>'center')),

               array(array('row'=>'HtmlTag'),array('tag'=>'tr'))



       ));

    $this->setDecorators(array(



               'FormElements',

               array(array('data'=>'HtmlTag'),array('tag'=>'table')),

               'Form'



       ));




        $this->addElements(array(
        $username,
        $password,
        $file,
        $captcha,
        $date1,
        $reg

        ));



        return $this;
    }


}
?>

ここで$date1->setDecorators()が機能しないと、次のようなエラーが表示されます。

: Cannot render jQuery form element without at least one decorator implementing the 'ZendX_JQuery_Form_Decorator_UiWidgetElementMarker' interface
4

1 に答える 1

1

DatePickerオブジェクトでViewHelperデコレータの代わりにUiWidgetElementデコレータを使用してみてください。

于 2012-07-30T09:03:45.420 に答える