I have a product search page where users can filter based on selected category.
When a category is chosen, the API returns the following response:
"customFields":{
"select":{
"brand":{"options":[ "nike", "adidas","puma"]},
"colour":{"options":["black","grey","white"]
},
"range":{
"price":{"options":["0","100","1000"]
}
}
The Select
fields are checkboxes allowing for multiple selections, while the Range
fields require users to select a minimum and maximum value.
To create the checkboxes, I have implemented the following code:
<div class="form-row" v-for="(selectField, index) in selectCustomFields">
<div class="overflow-auto options-list" v-for="(value, name) in selectField.options">
<label class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input" v-model="index" :value="value" @click="onChange($event)">
<span class="custom-control-label">
<span class="text-dark">{{ value }}</span>
</span>
</label>
</div>
</div>
How can I retrieve the values of all checked options in termQualities
?
Is there a way to create an array of checkboxes to store all selected values?
I am aiming for something similar to this example, with the only difference being that the sidebar filters change based on the product category.
Thanks!