activeDropDownList with listOptions

Hi all,

I'm getting a little confused trying to implement activeDropDownList with listData and listOptions.  I first tried it with just listData and everything is fine.  Here is the code:

<?php echo CHtml::activeDropDownList($list,'l_price', CHtml::listData($minmax_values, 'price', 'price')); ?>

When I try to add listOptions to add a default text of "Please Pick", i get a php error "cannot pass parameter 3 by reference".  Here is the code:

<?php echo CHtml::activeDropDownList($list,'l_price', CHtml::listOptions('l_price',(CHtml::listData($minmax_values, 'price', 'price')), array('prompt'=>'Please Pick'))); ?>

Any idea what I'm doing wrong? 

thanks

R

listOptions generates the HTML code, rather than the data array needed by activeDropDownList. It is actually used internally by activeDropDownList to render an array as the HTML options.

Hi Qiang,

Thanks for the reply.

I understand your reply, but I'm not closer to understanding the syntax to add a prompt field like "please select".  Can you be more specific please.

thanks

R

That is in the $htmlOptions parameter, not $listData.

OK, I got it.  The documentation is not very clear.  By reading it, I assumed I needed to use listOptions instead of listData and that's not the case at all.

Here is the code I used for anyone who may need it in the future.

R

<?php echo CHtml::activeDropDownList($list,'l_price', CHtml::listData($minmax_values, 'price', 'price'), array('prompt'=>'Please Select')); ?>

Thanks for your help.

R

I just realized that. I will fix it. Thanks.