availity-reactstrap-validation icon indicating copy to clipboard operation
availity-reactstrap-validation copied to clipboard

Update input value of AvForm after a component mounted

Open shakibamoshiri opened this issue 5 years ago • 4 comments

Hi, thanks for developing and maintaining this repo

When using AvForm the value of the form is set using the model={defaultValues} right? When the state is updated, how can we update the value of the from? I think it is set the first time and once. Am I wrong?

So I have to do something like this.

2020-01-16-131808_1600x900_scrot


        <AvForm model={defaultValues}>
          <AvField
            name="title"
            type="text"
            label="عنوان"
            value={defaultValues.title}
            validate={{
              required: { errorMessage: "این فیلد نباید خالی باشد" }
            }}
          />

if I do not use value={defaultValues.title} then the value is not updated after using componentDidMount

  componentDidMount() {
    this.getInfo(); // after calling this, value of AvForm should be updated, solution?
  }

shakibamoshiri avatar Jan 16 '20 10:01 shakibamoshiri

If you provide value then you take control of the input. Similar to plain <input>s within react. At that point, you have to listen for changes via onChange and set the value when it changes. The easy thing to do is just want for the defaults to load before showing the form.

TheSharpieOne avatar Jan 16 '20 15:01 TheSharpieOne

is there any way to update form when model update? @TheSharpieOne

hungdev avatar Sep 01 '20 16:09 hungdev

is there any way to update form when model update? @TheSharpieOne

Did u find a solution for this.

imdkbj avatar Feb 25 '21 06:02 imdkbj

We dont have a solution for this?

davinun99 avatar Dec 29 '22 14:12 davinun99