php - Zend Form: how to automatically set the class of an element to required if required option is set to true? -
is possible? i'm trying use jorn's jquery validation plugin, , avoid having add 'class' => 'required' if i'm setting required => true option. thx in advance input!
not possible using standard zf classes. can accomplish creating custom decorator replace standard viewhelper
.
class my_form_decorator_viewhelper extends zend_form_decorator_viewhelper { public function render($content) { $element = $this->getelement(); if ($element->isrequired()) { $class = $element->getattrib('class'); // append current attrib $element->setattrib('class', $class . ' required'); } return parent::render($content); } }
of course, might want add prefix path decorator in form.
Comments
Post a Comment