Form isn't validating input inside self-closing component


(Allan Ramos) #1

Hi guys, i’m having a problem trying to validate a input inside another component.

I have a Form component that validates all inputs inside him. Like this:

<Form
   validation={{
      amount: [required],
   }}
>
   <input type="text" name="amount" /> 
</Form>

It works fine. The Form will go through his children (the inputs) and validate it.

Now, let’s see another case, inserting a self-closing component inside the Form:

<Form
   validation={{
      amount: [required],
   }}
>
   <ComponentWithInputs />
</Form>

The Form lib implementation will look for all children to verify if the input match with the validation, but in this case, the form library doesn’t find any input inside ComponentWithInputs.

There is a way to make this validation works?

Form library