php - Add options with same values but different Caption using addMultioption in zend form -


i'm creating select box using zend form element. i've list of values displayed in selectbox may have same values different captions. zend forms wont display 2 options same value. code follows:

$this->addmultioption('','-- select ****** --'); foreach($options $option) {     $this->addmultioption($option->value,$option->caption); } 

here values options can same 1,2,3,4,1,2,6,7,8,2,3,2,1... , caption options different aaa,bbb,ccc,ddd,eee,fff

aaa can have value 1, bbb can have value 1 in case show bbb , on.

is there way make work?

thanks in advance.

you can see implementation of addmultioption here. you'll notice cast option string , force value on it, overwriting previous values have found out.

/**  * add option  *  * @param  string $option  * @param  string $value  * @return zend_form_element_multi  */ public function addmultioption($option, $value = '') {     $option  = (string) $option;     $this->_getmultioptions();     if (!$this->_translateoption($option, $value)) {         $this->options[$option] = $value;     }      return $this; } 

possibile solutions might add suffix options random character string cut off when analyzing. create distinct options , map them mapping array.

<select>     <option value="car">car</option>     <option value="toy">toy</option> <select> 

with array

$mapping = array(     'car' => 'car',     'toy' => 'car' );  $truevalue = $mapping[$formoption]; 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -