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

Uncaught (in promise) TypeError: Cannot read property 'validations' of undefined

Open AbhaysinghBhosale opened this issue 4 years ago • 7 comments

Getting this issue when AvFields are rendered dynamically. AvForm.js:525 Uncaught (in promise) TypeError: Cannot read property 'validations' of undefined my code is as follows <AvForm className='form-horizontal' onSubmit={this.handleSubmit}> {this.renderFormFeild()} {this.renderButton()} </AvForm>

renderFormFeild() function returned different form field as per current state and state get changed on radio outside the form. When i change any text in input field get this issue.

AbhaysinghBhosale avatar Sep 25 '19 08:09 AbhaysinghBhosale

It sounds like you may be setting up your form fields wrong. Make sure you are using the name prop when creating each input. That is the name that gets registered with the form validation context and returns all of those validations that you are seeing as undefined.

GoPro16 avatar Sep 25 '19 13:09 GoPro16

@GoPro16 i have two type of form fields/input. Type 1 fields returned if state is true and Type 2 fields are returned if state is false.

In the DOM i can see the field with name attr. but on input focus/change it triggers error.

AbhaysinghBhosale avatar Sep 29 '19 06:09 AbhaysinghBhosale

Can you please post a code sandbox link with your issue. There may just be some minor configuration you are doing wrong or its an edge case bug that I cannot seem to follow.

GoPro16 avatar Sep 29 '19 22:09 GoPro16

I'm also getting this err. It comes up when trying to insert a field into a form with another component:

  const EVField = props_ => (
    <AvField
      type="number"
      validate={{
        min: { value: 0 },
        max: { value: 252 }
      }}
      name={props_.name} />
  );

<AvForm>
   <EVField name="name" />
</AvForm>

JonoAugustine avatar Nov 07 '19 03:11 JonoAugustine

I am getting the same error. It looks like it is coming the name. I am using a form to create some array this way: <AvField required type="date" name={'partialShipment[' + index + '][endOfProduction]'} id={'partialShipment[' + index + '][endOfProduction]'} /> and that seems to be the problem...

millerf avatar Jan 15 '20 13:01 millerf

Hi,

anyone has a solution for it?

hpsharon avatar May 09 '20 16:05 hpsharon

Anyone has a solution for it?

What happened to @JonoAugustine also happens to me.

ReneGustavo avatar Oct 08 '21 14:10 ReneGustavo