#Form validation is not being shown onSubmit

8 messages · Page 1 of 1 (latest)

shell musk
#

Hi, I've added the validation function on useForm.

Then I passed the form into a component, and I have there the <form onSubmit={form.onSubmit(handleSubmit, handleErrors)} /> tag.

If I click on Validate button, it shows the red buttons, but If I click the button that submits the form, I don't get the errors in red but a popup saying required field.

So form.validate() does show the erros as expected.
form.onSubmit(handleSubmit) does not. (It shows the default popup)

My form:

    const productForm = useForm<CreateUpdateProductDTO>({
        initialValues: {...product, price: product.basePrice, categoryId: product.category.id },
        validate: {
            name: (value) => (!value ? 'Mandatório' : null),
            price: (value) => (!value ? 'Obrigatório' : null),
            taxId: (value) => (!value ? true : null),
            sku: (value) => (!value ? true : null),
            status: (value) => (!value ? true : null),
        }
    });

Any idea? :/

shell musk
#

@errant tangle

errant tangle
fair anvil
fair anvil
#

required attribute is causing to show default popup

shell musk
#

I'm using withAsterisk and not required

#

Oops, nevermind I had 1 required there and was messing everything up