开发者

Zend decorators: How can I use jquery-ui classes on my forms?

I create a form in a Zend Framework using jquery:

    class Contact_Form_Contact extends ZendX_JQuery_Form {

  public function init() {
        /* Form Elements & Other Definitions Here ... */
        //create new element
        $name = $this->createElement('text', 'name');
        //element options
        $name->setLabel("Enter your name:");
        $name->setRequired(TRUE);
        $name->setAttrib('size', 40);
        //add element to the form

        $this->开发者_高级运维addElement($name);
        .....

If request fails setRequired enables class=errors,

How to override it to "ui-state-error my-clean"?

Arman.


Instead of overwriting decorators, you can set decorator options that way:

$element->getDecorator('Errors')->setOption('class', 'ui-state-error my-clean')


After seriously reading the blogs of Zend I found that it is very easy to do that with decorator:

  $this->setElementDecorators(array(
        'ViewHelper',
        'Label',
        array('Errors', array('class'=>'ui-state-error'))
    ));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜