A little strange in CHtml::listOptions()

Hi All,

I used this framework for a while and feel very comfortable about how methods go. They almost go in the same way. ;) Anyway, I’ve just used the CHtml::listOptions() for the first time and feel strange about it.

First,

The "htmlOptions" parameter should be additional like any others.

Second,

Since now, as a required parameter, It should not force to use only referenced variable so the user can use a direct array() data type as an option.

I think this issue might not going to be in a bug report since the function itself work just fine, so there’s a little suggestion.

reported from Yii 1.1.2

Best regards,

Poo

Please provide some code showing how are you using it. Thanks.

This is a normal case when you want to add htmlOptions parameter.




// without htmlOptions

echo CHtml::radioButton('name', true);


// with htmlOptions

echo CHtml::radioButton('name', true, array('id' => '_id'));


// or

$htmlOptions = array('id' => '_id');

echo CHtml::radioButton('name', true, $htmlOptions);



Here’s when you want to add the parameter to CHtml::listOptions().




// there's the only way to add

$htmlOptions = array('id' => '_id');

echo CHtml::listOptions('selectedElement', $data, $htmlOptions);


// can't go like this

echo CHtml::listOptions('selectedElement', $data, array('id' => '_id'));  // generate a fatal error: Cannot pass parameter 3 by reference in ...