2012-07-30 73 views
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()不工作這是給我這樣一個錯誤:Zend Framework的日期選擇裝飾

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

回答

1

嘗試使用UiWidgetElement裝飾,而不是視圖助手裝飾你的DatePicker對象。