Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select option another properties #186

Closed
icetee opened this issue Apr 29, 2017 · 4 comments
Closed

Select option another properties #186

icetee opened this issue Apr 29, 2017 · 4 comments

Comments

@icetee
Copy link

icetee commented Apr 29, 2017

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>
@lionel-bijaoui
Copy link
Member

lionel-bijaoui commented May 2, 2017

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'
  }
}

@cristijora
Copy link
Collaborator

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

@lionel-bijaoui
Copy link
Member

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

@icebob
Copy link
Member

icebob commented May 2, 2017

I merged. Thanks @lionel-bijaoui !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants