Reputation: 70416
Hi have a dropdown list that is filled with data from database.
<select name="form[entities][]" multiple="true">
{% for entity in entities %}
{% if entity.selected %}
<option value="{{ entity.id }}" selected="selected">
{{ entity.name }}
</option>
{% else %}
<option value="{{ entity.id }}">{{ entity.name }}</option>
{% endif %}
{% endfor %}
</select>
If an entity was previously slected it will be rendered as selected.
I can switch selections, that means I can select another entity and the previous one will be deselected. But e.g. if there is only one item and it is selected it cannot be deselected it simply stays selected.
So my question is, is this normal behaviour? The field is not required. Is there a way to handle deselection just using html or do I have to introduce another button and handle deselection with javascript?
Upvotes: 0
Views: 174
Reputation: 36
There are a couple of possible answers
Upvotes: 2