How to disable a form element in a Zend Form?

Viewed 36703

I want to display a Zend Form with one of the elements shown as disabled. I'm setting the value so the user can see it, but I want to disable it so the user can't edit it. This may also involve some sort of css/javascript to ensure that it looks like, and is not editable by the user. This is my element:

    $this->addElement('text', 'username', array(
        'label'      => 'Username:',
        'required'   => true,
        'filters'    => array('StringTrim'),
        'validators' => array(
            array('StringLength', false, array(2, 50))
        )
    ));
9 Answers
Related