Return to Snippet

Revision: 28989
at July 18, 2010 06:00 by postNuKe


Initial Code
Form.php

$this->addElement(
  'select', 
  'select_name', 
  array(
    'label' => 'Element Text Label:',
    'required' => true, 
    'multiOptions' => array('value1' => 'text1', 'value2' => 'text2', 'value3' => 'text3', 'value4' => 'text4'),
    //'disable' => array('value2', 'value3')
  ); 


Controller.php
//$selOptions = array('value1' => 'text1', 'value2' => 'text2', 'value3' => 'text3', 'value4' => 'text4');
//$form->getElement('select_name')->addMultiOptions($selOptions);
$form->getElement('select_name')->setAttrib('disable', array('value2', 'value3'));

Initial URL


Initial Description
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.

Initial Title
Zend Framework - Form Element Select Options Disable

Initial Tags
form

Initial Language
PHP