Zend Framework - 如何禁用文本框

时间:2010-10-29 07:23:15

标签: zend-framework zend-form

我在我的项目中使用zend_form。在表单中,我想禁用文本框。这是代码:

$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,
   ))
  )
 ));

如何在zend_form中禁用文本框?

1 个答案:

答案 0 :(得分:3)

这是一个禁用和只读文本字段的示例

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

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

我认为这种方式比向表单添加元素的方式更清晰,