views:

24

answers:

1

Hi,

I am using zend_form in my project. In a form i want to disable a text box. Here is the code:

$personal_information = new Zend_Form(array(
  'method'   => 'post',
  'elements' => array(
   'first_name' => array('text', array(
    'required' => true,
    'filters'    => array('StringTrim'),
    'validators' => array(
     array('NotEmpty', true),
     array(),
     array('stringLength', false, array(1, 40))
    ),
    'decorators' => $elementDecorators,
    'label' => 'First name:'
   )),
   // THE "NEXT" BUTTON
   'signup' => array('submit', array(
    'decorators' => $buttonDecorators,
    'label' => 'Next',
    'required' => false,
    'ignore'   => true,
   ))
  )
 ));

How to disable a text box in zend_form?

+2  A: 

here is an example of disabled and readonly text field

   $lati = new Zend_Form_Element_Text("lati" , array("readonly" => "readonly"));

   $lati = new Zend_Form_Element_Text("lati" , array("disabled" => "disabled"));

i think this way is more clear than the way you add elements to the form ,

tawfekov