Skip to content

Commit

Permalink
Update selectMultiple-input.html.twig
Browse files Browse the repository at this point in the history
Fixing the value assigning by iterating over the value property, that here is an array, to correctly determine the selected items on the select element.
  • Loading branch information
silvamfilipe committed Jan 24, 2015
1 parent efa21cc commit 9b361ef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Slick/Form/Template/Views/selectMultiple-input.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
{% block inputElement %}
<select name="{{ element.getName }}[]" id="{{ element.getName() }}-input" {{ element.getHtmlAttributes|raw }}>
{% for key, value in element.getOptions() %}
{% if key == element.getValue() %}
{% set selected = false %}
{% for val in element.getValue() %}
{% if key == val %}
{% set selected = true %}
{% endif %}
{% endfor %}
{% if selected %}
<option selected="selected" value="{{ key }}">{{ value }}</option>
{% else %}
<option value="{{ key }}">{{ value }}</option>
{% endif %}
{% endfor %}
</select>
{% endblock %}
{% endblock %}

0 comments on commit 9b361ef

Please sign in to comment.