File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -132,3 +132,45 @@ If you want added tags to be pushed to the options array, set `push-tags` to tru
132
132
133
133
<v-select taggable multiple push-tags />
134
134
135
+ ### Using ` taggable ` & ` reduce ` together
136
+
137
+ When combining ` taggable ` with ` reduce ` , you must define the ` createOption ` prop. The
138
+ ` createOption ` function is responsible for defining the structure of the objects that Vue Select
139
+ will create for you when adding a tag. It should return a value that has the same properties as the
140
+ rest of your ` options ` .
141
+
142
+ If you don't define ` createOption ` , Vue Select will construct a simple object following this structure:
143
+ ` {[this.label]: searchText} ` . If you're using ` reduce ` , this is probably not what your options look
144
+ like, which is why you'll need to set the function yourself.
145
+
146
+ ** Example**
147
+
148
+ We have a taggable select for adding books to a collection. We're just concerned about getting the
149
+ book title added, and our server side code will add the author details in a background process. The
150
+ user has already selected a book.
151
+
152
+ ``` js
153
+ const options = [
154
+ {
155
+ title: " HTML5" ,
156
+ author: {
157
+ firstName: " Remy" ,
158
+ lastName: " Sharp"
159
+ }
160
+ }
161
+ ];
162
+ ```
163
+
164
+ ``` html
165
+ <v-select
166
+ taggable
167
+ multiple
168
+ label =" title"
169
+ :options =" options"
170
+ :create-option =" book => ({ title: book, author: { firstName: '', lastName: '' } })"
171
+ :reduce =" book => `${book.author.firstName} ${book.author.lastName}`"
172
+ />
173
+ ```
174
+
175
+
176
+
You can’t perform that action at this time.
0 commit comments