views:

20

answers:

2

I want to add a specific class to an input if an error is genereted by the input.

For example, if input is empty and has required validator it shouls look like this:

<dd id="login-element">
    <input type="text" name="login" id="login" value="" class="input-text error" />
    <ul class="errors">
        <li>Value is required and can't be empty</li>
    </ul>
</dd>

class="input-text error"

Please tell me how to do that.

A: 

I've just realized that according to specification it is impossible to do without modification to framework structure or creating a custom plugin. Thank you anyway.

Kamil Mroczek
A: 

Have a look at this tutorial to get a better understanding where to change your code: http://devzone.zend.com/article/3450-Decorators-with-Zend_Form

In your case, I would recommend either replacing the ViewHelper decorator with a decorator that creates the output you want. You can extend the Zend_Form_Decorator_ViewHelper class for this with your own code and overwrite the getElementAttribs() method to insert your class attribute.

chiborg