Deselected/Unselected Option unavailable in single select

Issue #2 new
Nikolas Grottendieck
created an issue

I am not entirely sure whether this is a usage problem by myself but using

CHtml::listData(Model::model()->findAll(array('order' => 'full_name')), 'id', 'display')

to fill in the values array there is no "void" option in the generated chosen-widget, i.e. some option is always selected on submit, even if the chosen widget was never manipulated.

The Chosen documentation clearly states the option for a way to deselect any selected value: When a single select box isn't a required field, you can set allow_single_deselect: true and Chosen will add a UI element for option deselection. This will only work if the first option has blank text.

My guess would be that no blank first option is added automatically?

Comments (2)

  1. Bogdan Savluk repo owner

    Yeah, you are right it is not added automaticaly.

    I have not added this, in order to keep avaliable tools more consistent, because when using Chtml::dropDownList, or even simple html you also should add empty element manualy. So for now if you want use Chosen helper functions instead of CHtml ones - the only thing you need is to replace CHtml by Chosen, everything else will work out of box).

    You should add option with empty text manually, like this:

  2. Log in to comment