@@ -128,10 +128,7 @@ inline html (i.e. `<i>`, `<strong>`, etc) inside `<option>` elements of a `<sele
128128 user supplied string.
129129</p >
130130
131- If you want to customize fields (for example using ` name ` field for display text) you can easily
132- change them using ` text-field ` , ` html-field ` , ` value-field ` , and ` disabled-field ` props.
133-
134- ### Array
131+ ### Options as an array
135132
136133<!-- eslint-disable no-unused-vars -->
137134
@@ -141,10 +138,10 @@ const options = ['A', 'B', 'C', { text: 'D', value: { d: 1 }, disabled: true },
141138
142139If an array entry is a string, it will be used for both the generated ` value ` and ` text ` fields.
143140
144- You can mix using strings and [ objects] ( #objects ) in the array.
141+ You can mix using strings and [ objects] ( #options-as-an-array-of- objects ) in the array.
145142
146143Internally, BootstrapVue will convert the above array to the following array (the
147- [ Array of Objects ] ( #array-of-objects ) format:
144+ [ array of objects ] ( #options-as-an- array-of-objects ) ) format:
148145
149146<!-- eslint-disable no-unused-vars -->
150147
@@ -159,7 +156,7 @@ const options = [
159156]
160157```
161158
162- ### Array of objects
159+ ### Options as an array of objects
163160
164161<!-- eslint-disable no-unused-vars -->
165162
@@ -177,7 +174,7 @@ If `value` is missing, then `text` will be used as both the `value` and `text` f
177174the ` html ` property, you ** must** supply a ` value ` property.
178175
179176Internally, BootstrapVue will convert the above array to the following array (the
180- [ Array of Objects ] ( #array-of-objects ) format:
177+ [ array of objects ] ( #options-as-an- array-of-objects ) ) format:
181178
182179<!-- eslint-disable no-unused-vars -->
183180
@@ -187,12 +184,11 @@ const options = [
187184 { text: ' Item 2' , value: ' second' , disabled: false },
188185 { html: ' <b>Item</b> 3' , value: ' third' , disabled: true },
189186 { text: ' Item 4' , value: ' Item 4' , disabled: false },
190- { text: ' Item 5' , value: ' E' , disabled: false },
191- { text: ' F' , value: { foo: ' bar' , baz: true }, disabled: false }
187+ { text: ' Item 5' , value: ' E' , disabled: false }
192188]
193189```
194190
195- ### Object
191+ ### Options as an object
196192
197193Keys are mapped to ` value ` and values are mapped to option ` text ` .
198194
@@ -209,7 +205,7 @@ const options = {
209205```
210206
211207Internally, BootstrapVue will convert the above object to the following array (the
212- [ Array of Objects ] ( #array-of-objects ) format:
208+ [ array of objects ] ( #options-as-an- array-of-objects ) ) format:
213209
214210<!-- eslint-disable no-unused-vars -->
215211
@@ -219,12 +215,52 @@ const options = [
219215 { text: ' Item B' , value: ' b' , disabled: false },
220216 { html: ' Item C' , value: ' c' , disabled: false },
221217 { text: ' Item D' , value: ' overridden_value' , disabled: true },
222- { text: ' E' , value: { foo: ' bar' , baz: true }, disabled: false }
218+ { text: ' Item E' , value: { foo: ' bar' , baz: true }, disabled: false }
223219]
224220```
225221
226- ** Note:** When using the [ Object] ( #object ) format, the order of the final array is ** not**
227- guaranteed. For this reason, it is recommended to use the above array formats.
222+ ** Note:** When using the Object format, the order of the final array is ** not** guaranteed. For this
223+ reason, it is recommended to use either of the previously mentioned array formats.
224+
225+ ### Changing the option field names
226+
227+ If you want to customize the field property names (for example using ` name ` field for display
228+ ` text ` ) you can easily change them by setting the ` text-field ` , ` html-field ` , ` value-field ` , and
229+ ` disabled-field ` props to a string that contains the property name you would like to use:
230+
231+ ``` html
232+ <template >
233+ <div >
234+ <b-form-select
235+ v-model =" selected"
236+ :options =" options"
237+ class =" mb-3"
238+ value-field =" item"
239+ text-field =" name"
240+ disabled-field =" notEnabled"
241+ ></b-form-select >
242+ <div class =" mt-3" >Selected: <strong >{{ selected }}</strong ></div >
243+ </div >
244+ </template >
245+
246+ <script >
247+ export default {
248+ data () {
249+ return {
250+ selected: ' A' ,
251+ options: [
252+ { item: ' A' , name: ' Option A' },
253+ { item: ' B' , name: ' Option B' },
254+ { item: ' D' , name: ' Option C' , notEnabled: true },
255+ { item: { d: 1 }, name: ' Option D' }
256+ ]
257+ }
258+ }
259+ }
260+ </script >
261+
262+ <!-- b-form-select-options-fields.vue -->
263+ ```
228264
229265### Option notes
230266
0 commit comments