Yii - How To Insert A Placeholder In The Dropdownlist

I’m new to Yii framework. I created dropdownlists using the below code -




    echo $form->dropDownList($model, 'min_cost', Yii::app()->params['cost_resales']);

    echo $form->dropDownList($model, 'max_cost', Yii::app()->params['cost_resales']); 



Now, I cannot insert a place holder, in the above dropdownlists. I tried using the below htmloptions to insert placeholder




    array('empty'=>'Min')

    array('empty'=>'Max')  



This works fine. But , this values get included in dropdownlist also. I don’t want them to be included in dropdownlist.

I’m using the below Jquery code to populate the dropdownlist values.




    <script>

    jQuery(function(){ 

       // Keep a copy of the default options

        var $options = jQuery('#SearchForm_min_cost').children().clone();

        

        

        jQuery('#SearchForm_min_cost').change(function(){

    

        // Within your change handler:

        

            var index = jQuery(this).find(':selected').index();

            jQuery('#SearchForm_max_cost').html($options).children(':lt('+index+')').remove();

        

        }); 

    

    });

    </script>



How can I not include this values along with the list. I want them to be as placeholder and not in the list.

I tried prompt also, even this is included in the selection list.




array(

    'prompt'=>'Please select the minimum value',

));



I don’t think you can do what you want with a standard HTML select box.

Why do you want to avoid including the prompt as a selectable option? If the prompt entry is chosen, it will have the same effect as leaving the drop down list empty, so you can ensure a valid value is selected by having a ‘required’ rule for that field.