File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{% block sylius_gally_filter_checkbox_row -%}
22 <div class =" {% if required %}required {% endif %}field{% if (not compound or force_error | default (false )) and not valid %} error{% endif %}" >
33 {{- form_label(form ) -}}
4- {% set choices = {} %}
4+ {% set choices = [] %}
55 {% for choice in form .vars .choices %}
6- {% set choices = choices | merge ({(choice .label ): choice .value }) %}
6+ {# merge() renumbers integer-like keys (PHP array_merge behavior), so labels that
7+ look like numbers (e.g. "12") must not be used as array keys: kept as a list of
8+ {label, value} pairs instead. #}
9+ {% set choices = choices | merge ([{label : choice .label , value : choice .value }]) %}
710 {% endfor %}
811 {{ component(' gally_shop:filter:facet_options' , {
912 filterField : form .vars .name ,
Original file line number Diff line number Diff line change 1212 </div >
1313 {% endif %}
1414 <div class =" ui" >
15- {% for label , value in choices %}
15+ {% for choice in choices %}
1616 <div class =" form-check" >
1717 <input type =" checkbox" class =" form-check-input"
1818 id =" {{ baseId }}_{{ loop .index0 }}"
1919 name =" {{ fieldName }}[]"
20- value =" {{ value }}"
21- {% if value in selectedValues %}checked {% endif %}>
22- <label class =" form-check-label" for =" {{ baseId }}_{{ loop .index0 }}" >{{ label }}</label >
20+ value =" {{ choice . value }}"
21+ {% if choice . value in selectedValues %}checked {% endif %}>
22+ <label class =" form-check-label" for =" {{ baseId }}_{{ loop .index0 }}" >{{ choice . label }}</label >
2323 </div >
2424 {% endfor %}
2525 </div >
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ class FacetOptionsComponent
4848 #[LiveProp]
4949 public string $ baseId = '' ;
5050
51- /** @var array< string, string> */
51+ /** @var list<array{label: string, value: string} > */
5252 #[LiveProp]
5353 public array $ initialChoices = [];
5454
@@ -97,7 +97,7 @@ public function viewMore(): void
9797 }
9898
9999 /**
100- * @return array< string, string>
100+ * @return list<array{label: string, value: string} >
101101 */
102102 #[ExposeInTemplate('choices ' )]
103103 public function getChoices (): array
@@ -116,7 +116,7 @@ public function getChoices(): array
116116 /** @var array<string, string> $option */
117117 foreach ($ aggregationOptions as $ option ) {
118118 if (isset ($ option ['label ' ])) {
119- $ choices [$ option ['label ' ]] = $ option ['value ' ] ?? '' ;
119+ $ choices [] = [ ' label ' => $ option ['label ' ], ' value ' => $ option ['value ' ] ?? '' ] ;
120120 }
121121 }
122122
You can’t perform that action at this time.
0 commit comments