fulanku
(T1)
March 19, 2012, 1:35pm
1
Hi out there,
I have a strange behavior of activeDropDownList. I can set strings as value but not numbers , they are instead index starting with 0.
generating with:
<?php
echo CHtml::activeDropDownList($model, "status",
array_merge(array(''=>Yii::t('offer', '- Status festlegen -')),array('-9'=>'minus neun', '2'=>'zwei')),
array('title'=>Yii::t('tooltips', 'offer. Status des Angebotes')));
?>
results in:
<select id="Offer_status" name="Offer[status]" title="offer. Status des Angebotes">
<option selected="selected" value="">- Status festlegen -</option>
<option value="0">minus neun</option>
<option value="1">zwei</option>
</select>
So what am i doing wrong here? Any Ideas…
Fu
fulanku
(T1)
March 20, 2012, 10:30am
2
fulanku:
Hi out there,
I have a strange behavior of activeDropDownList. I can set strings as value but not numbers , they are instead index starting with 0.
generating with:
<?php
echo CHtml::activeDropDownList($model, "status",
array_merge(array(''=>Yii::t('offer', '- Status festlegen -')),array('-9'=>'minus neun', '2'=>'zwei')),
array('title'=>Yii::t('tooltips', 'offer. Status des Angebotes')));
?>
results in:
<select id="Offer_status" name="Offer[status]" title="offer. Status des Angebotes">
<option selected="selected" value="">- Status festlegen -</option>
<option value="0">minus neun</option>
<option value="1">zwei</option>
</select>
So what am i doing wrong here? Any Ideas…
Fu
Is it so obvious or so hard to solve?
I really stuck on this one.
Fulanku
fulanku
(T1)
March 21, 2012, 9:59am
3
Solved.
Obviously a simple PHP issue.
array_merge dosen’t merge assoc arrays without reindexing.
array_merge( array( ''=>Yii::t( 'offer', '- Status festlegen -' )) ,array( '-9'=>'minus neun', '2'=>'zwei' ));
// dosen't merge assoc arrays without reindexing
// working example with $a und $b are of type array
$assoc_merged_array = array_diff_key($a + $<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='B)' /> +$b;
Sorry for bothering …