-- core <[EMAIL PROTECTED]> wrote
(on Thursday, 21 August 2008, 01:51 PM -0700):
> first of all: a great board! I've found a lot of solutions for my problems.
> But now I have a topic I cannot find any answer for:
> 
> I want to mark a field generated by Zend_Form with a custom style-class
> 'error-form' in addition to the display error-message.
> For example a input-field has to look like: <input type="text" ...
> class="error-form" />.
> Does there is any possibility getting such an output using the Decorator (or
> some else)-functionality?

Currently, there's no functionality with this. You could easily add a
decorator that simply adds a class to the element, however:

    class My_Decorator_AddErrorClass extends Zend_Form_Decorator_Abstract
    {
        public function render($content)
        {
            $element = $this->getElement();
            if ($element->hasErrors()) {
                if (isset($element->class)) {
                    $element->class .= ' error-form';
                } else {
                    $element->class = 'error-form';
                }
            }
            return $content;
        }
    }

Attach that as the first decorator in your decorator chain, and you'd be
good to go.

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend Framework           | http://framework.zend.com/

Reply via email to