javascript - How to give default value and placeholder to redux form select field? - Stack Overflow

I have array iterating options of redux form option... How I will give dafault value and place holder b

I have array iterating options of redux form option... How I will give dafault value and place holder because it shows the first value of array which don't want... I want to show the placeholder instead

  <Field
    name="facilityId"
    ponent="select"
    className="form-control"
    placeholder="sdsfdsafjdsafijdsaoi"
  >
    {owners.map((data, i) => {
      return (
        <option value={data._id} key={i}>{data.profile.name}</option>
      )
    })}
  </Field>

I have array iterating options of redux form option... How I will give dafault value and place holder because it shows the first value of array which don't want... I want to show the placeholder instead

  <Field
    name="facilityId"
    ponent="select"
    className="form-control"
    placeholder="sdsfdsafjdsafijdsaoi"
  >
    {owners.map((data, i) => {
      return (
        <option value={data._id} key={i}>{data.profile.name}</option>
      )
    })}
  </Field>
Share Improve this question edited Jun 4, 2018 at 18:08 Ashh asked Sep 18, 2017 at 11:09 AshhAshh 46.6k16 gold badges111 silver badges137 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

You can do the following

<ControlLabel>Patients</ControlLabel>
    <Field
        name="facilityId"
        ponent="select"
        className="form-control"
        placeholder="sdsfdsafjdsafijdsaoi"
    >
        <option value="-1" disabled>Choose patient</option>
        {owners.map((data, i) => {
            return (
                <option value={data._id} key={i}>{data.profile.name}</option>
            );
        })}
    </Field>
<FormControl.Feedback />

PS: Sorry if the formatting is off. I'm typing with my phone.

Using Redux-form, multiple select fields, and loading the options asynchronously - I had issues w/ the chosen answer not working 100% of the time. This works in my case. Notice the value is "".

<ControlLabel>Patients</ControlLabel>
<Field
    name="facilityId"
    ponent="select"
    className="form-control"
    placeholder="sdsfdsafjdsafijdsaoi"
>
    <option value="" disabled>Choose patient</option>
    {owners.map((data, i) => {
        return (
            <option value={data._id} key={i}>{data.profile.name}</option>
        );
    })}
</Field>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745396655a4625909.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信