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

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -