CHtml::listOptions restricts to pass htmlOptions as an inline array()

This is the scenario:


$cmd = conn()->createCommand($sql);

$rows = CHtml::listData($cmd->queryAll(),'id', 'name');

// it gives Fatal error: Cannot pass parameter 3 by reference.


$return = CHtml::listOptions('0', $rows, array('prompt'=>'','encode'=>true));



//This works perfect


$htmlOptions = array('prompt'=>'','encode'=>true);

$return = CHtml::listOptions('0', $rows, $htmlOptions);

// Here in CHtml::listOptions() the &$htmlOptions is passed BY REFERENCE.


public static function listOptions($selection,$listData,   &$htmlOptions   )

{ ...}



so if we do not pass htmlOptions by reference every where it works fine, also when it is passed as an inline array rathar than a array vaiable.

But why is this passed by reference? is this necessary for the framework?

so what’s the best practice of using this,especially in ActiveForm!

here it is




                    <?php echo CHtml::activeDropDownList( $toDo, 'priorityId', $user->getPriorityList(), array( 'encode' => false, 'options' => array( $user->config->priorityId => array('selected' => true) ) ) ); ?>




which refers to

http://www.yiiframework.com/forum/index.php?/topic/5491-activedropdownlist-and-html-in-option-label