Vue-form-generator: Select option another properties

Created on 29 Apr 2017  路  4Comments  路  Source: vue-generators/vue-form-generator

Hi, I would like to set default value, but I can't change Nothing selected value. And if id equal to 0 then the result is [object Object].

{
  type: "select",
  label: "Salutation",
  model: "salutation",
  featured: false,
  required: true,
  values: function() {
    return [
      { id: 0, name: "Please select", disabled: true },
      { id: 1, name: "Mr." },
      { id: 2, name: "Lady" },
      { id: 3, name: "Waitress" },
      { id: 4, name: "Disable test" }
    ]
  }
}
<select class="form-control">
    <option disabled="disabled" value="">&lt;Nothing selected&gt;</option>
    <option value="[object Object]">Please select</option>
    <option value="1">Mr.</option>
    <option value="2">Lady</option>
    <option value="3">Waitress</option>
    <option value="4">Disable test</option>
</select>

Most helpful comment

It seem to be undocumented (sorry about that), bur you can add and option under selectOptions called noneSelectedText. So from your example, it would look like that:

{
  type: "select",
  label: "Salutation",
  model: "salutation",
  featured: false,
  required: true,
  values: function() {
    return [
      { id: 1, name: "Mr." },
      { id: 2, name: "Lady" },
      { id: 3, name: "Waitress" },
      { id: 4, name: "Disable test" }
    ]
  },
  selectOptions: {
    noneSelectedText: 'Please select'
  }
}

All 4 comments

It seem to be undocumented (sorry about that), bur you can add and option under selectOptions called noneSelectedText. So from your example, it would look like that:

{
  type: "select",
  label: "Salutation",
  model: "salutation",
  featured: false,
  required: true,
  values: function() {
    return [
      { id: 1, name: "Mr." },
      { id: 2, name: "Lady" },
      { id: 3, name: "Waitress" },
      { id: 4, name: "Disable test" }
    ]
  },
  selectOptions: {
    noneSelectedText: 'Please select'
  }
}

Damn this is useful.. Sad I didn't know about it

I didn't knew about it either, I just checked the sources. I did a pull on the documentation, just waiting for @icebob to merge the changes

I merged. Thanks @lionel-bijaoui !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Stephen9s picture Stephen9s  路  4Comments

LouWii picture LouWii  路  4Comments

dflock picture dflock  路  5Comments

gkurdej picture gkurdej  路  5Comments

icebob picture icebob  路  4Comments