Availity / availity-reactstrap-validation

Easy to use React validation components compatible for reactstrap.
https://availity.github.io/availity-reactstrap-validation/
MIT License
191 stars 70 forks source link

Update input value of AvForm after a component mounted #175

Open shakibamoshiri opened 4 years ago

shakibamoshiri commented 4 years ago

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?
  }
TheSharpieOne commented 4 years ago

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.

hungdev commented 4 years ago

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

imdkbj commented 3 years ago

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

Did u find a solution for this.

davinun99 commented 1 year ago

We dont have a solution for this?