Posted By

postNuKe on 07/18/10


Tagged

form select element options Framework disable zend


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

osirisinternet
piotrlewandowski


Zend Framework - Form Element Select Options Disable


 / Published in: PHP
 

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.

  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  

You need to login to post a comment.