2009年6月29日星期一

Re: [fw-mvc] Form Decorator Method getLabel does not exist

It's because the Label decorator calls getLabel() on the object it decorates, but there's no such method in a form object. The Label decorator is for elements, not the form itself.

   -- Mon


On Mon, Jun 29, 2009 at 4:06 PM, whisher <whisher@mp4.it> wrote:

Hi.
Can you explain me why on earth this code get
the error in the subject:
class Form_User extends Zend_Form
{
   public function init()
   {
       $this->setMethod('post');
       $this->setAttribs(array('id'=>'frm-user','class'=>'large center'));
       // Name
       $this->addElement('text', 'uname', array(
           'maxlength' => 50,
           'label'      => 'form_User_Label_Name',
           'required'   => true,
           'filters'    => array('StringTrim'),
           'validators' => array(
               'Alnum',
               array('StringLength', true, array(3, 50)),
               array('Db_NoRecordExists', false, array('table' => 'users',
                                                              'field' =>
'uname'))
           )
       ));

       $this->setDisableLoadDefaultDecorators(true);
       $this->setDecorators(array(
               'formElements',
               array('HtmlTag', array('tag' => 'dl', 'class' =>
'elements-frm-user')),
               array('Label', array('tag' => 'dd', 'class' =>
'labels-frm-user')),
               'Form'
       ));

   }
}

Bye.
--
View this message in context: http://www.nabble.com/Form-Decorator-Method-getLabel-does-not-exist-tp24249990p24249990.html
Sent from the Zend MVC mailing list archive at Nabble.com.


没有评论: