Преглед изворни кода

Fix missing selected value on Select2 v4 autocomplete

Sullivan SENECHAL пре 8 година
родитељ
комит
05a128a94e
1 измењених фајлова са 3 додато и 0 уклоњено
  1. 3 0
      Resources/views/Form/Type/sonata_type_model_autocomplete.html.twig

+ 3 - 0
Resources/views/Form/Type/sonata_type_model_autocomplete.html.twig

@@ -21,6 +21,9 @@ file that was distributed with this source code.
         {%- if disabled %} disabled="disabled"{% endif -%}
         {%- if required %} required="required"{% endif %}
     >
+        {%- for idx, val  in value if idx~'' != '_labels' -%}
+            <option value="{{ val }}" selected>{{ value['_labels'][idx] }}</option>
+        {%- endfor -%}
     </select>
 
     <div id="{{ id }}_hidden_inputs_wrap">