Zend Framework - Form Element Select Options Disable


/ Published in: PHP
Save to your folder(s)

On Zend Framework you can add options on Select Element on Form.php or Controller Action, and after you can disable it, on Form.php or Controller.php too.


Copy this code and paste it in your HTML
  1. Form.php
  2.  
  3. $this->addElement(
  4. 'select',
  5. 'select_name',
  6. 'label' => 'Element Text Label:',
  7. 'required' => true,
  8. 'multiOptions' => array('value1' => 'text1', 'value2' => 'text2', 'value3' => 'text3', 'value4' => 'text4'),
  9. //'disable' => array('value2', 'value3')
  10. );
  11.  
  12.  
  13. Controller.php
  14. //$selOptions = array('value1' => 'text1', 'value2' => 'text2', 'value3' => 'text3', 'value4' => 'text4');
  15. //$form->getElement('select_name')->addMultiOptions($selOptions);
  16. $form->getElement('select_name')->setAttrib('disable', array('value2', 'value3'));

Report this snippet


Comments


You need to login to view comments.