GoofyX
(Forum)
June 16, 2009, 7:09am
1
I have this in my view:
echo CHtml::dropDownList('User[groups][]', $selected_groups, $groups, array('multiple'=>'multiple', 'style'=>'height: auto'));
However, it does not work. No additional attributes appear in the generated [tt]<select>[/tt] tag. What's wrong?
GoofyX
(Forum)
June 16, 2009, 2:30pm
3
It's an array with the data for the options. Example:
array
1 => string 'Διαχειριστές' (length=24)
3 => string 'Εκτός κεντρικού' (length=29)
2 => string 'Εντός κεντρικού' (length=29)
4 => string 'Μόνο για ανάγνωση' (length=32)
(using [tt]var_dump($groups)[/tt])
Spyros
(Spyros)
June 16, 2009, 3:23pm
4
I used your code
<?php
$selected_groups = "Διαχειριστές";
$groups = array(1 => 'Διαχειριστές', 3 => 'Εκτός κεντρικού',
2 => 'Εντός κεντρικού',
4 =>'Μόνο για ανάγνωση' );
?>
<?php echo CHtml::dropDownList('User[groups][]', $selected_groups,
$groups, array('multiple'=>'multiple', 'style'=>'height: auto'));
?>
and i get this html
<select multiple="multiple" style="height: auto" name="User[groups][]" id="User_groups">
<option value="1">Διαχειριστές</option>
<option value="3">Εκτός κεντρικού</option>
<option value="2">Εντός κεντρικού</option>
<option value="4">Μόνο για ανάγνωση</option>
</select>
It seems to work correctly
GoofyX
(Forum)
June 16, 2009, 3:40pm
5
OK, this is getting weird. I spent about half an hour at a Windows XP PC with Xampp lite wondering why the code above did not work (I mean the extra array with the html options). In my other development PC (Linux, the one I'm sitting in front of right now), it works…
I will test again tomorrow at the Windows box. Thank you guys.