Skip to content

Commit

Permalink
fix: Allow a multi-select to be emptied (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
staylorwr authored Jul 1, 2024
1 parent 97895f6 commit c4b9d1a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions assets/src/components/Form/MultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,30 @@ export default {
mixins: [HandlesValidationErrors, FormField],
data: () => ({
value: false,
value: [],
options: [],
}),
computed: {
useCards() {
useCards () {
return !!this.field.options[0].title;
},
},
mounted() {
this.value = this.field.value || false;
mounted () {
this.value = this.field.value || [];
this.options = this.field.options;
this.field.fill = (formData) => {
if (this.value) {
console.log(this.value);
if (this.value && this.value.length > 0) {
this.value.forEach((option) => {
formData.append(`${this.field.attribute}[]`, option.value);
});
return;
}
if (this.value && this.value.length === 0) {
formData.append(`${this.field.attribute}[]`, []);
}
};
},
Expand Down

0 comments on commit c4b9d1a

Please sign in to comment.