2008年11月10日星期一

[fw-mvc] Custom Error Form

Hi
I used the code (take from the forum) below to change the class of an
element(of an form) if there was some mistake, but does not work...

This is a function of my class that exstends Zend_Form
> public function isValid($formData) {
> $isValid = parent::isValid($formData);
> if(!$isValid) {
> $errors = $this->getErrors();
>
> foreach($errors as $fn => $error) {
> if(empty($error)) continue;
> $el = $this->getElement($fn);
> $dec = $el->getDecorator('HtmlTag');
> $dec->setOption('class', 'error');
> }
> }
> return $isValid;
> }
and have used this code for decorator of elementes:

> $elementDecorators = array(
>
> 'ViewHelper',
> array('HtmlTag',array('tag' => 'td', 'class' => 'element')),
> array('Label', array('tag' => 'td'),
> array(array('row' => 'HtmlTag'), array('tag' => 'tr'))));
the decorator worw but only not change the class in case of error.

Thank you for your attention
PS:Sorry for my English, are Italian

没有评论: