Sometime we may wish to disable elements on a form. For instance, we may share the same form for adding and editing a record, and a particular field is read only when editing. When working with Zend_Form, we can use the setAttrib function of a form element to perform this task.
Some elements (e.g. text elements) are disabled by making them read only. Assuming the for element is represented by the variable $element, we can do this by:
For other elements (e.g. select elements), we set the disabled attribute to disabled by: