You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to determine the validation rules for a given field from within the field component? I want to do this to be able to provide the correct HTML attributes without excessive repetition.
I want to be able to provide the required, maxLength, etc attributes to the <input> element, but without needing to pass them to the component rendering as well as when constructing the validator. Instead I'd like to have some way to infer these from the form itself - from either useFieldContext or useFormContext.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to determine the validation rules for a given field from within the field component? I want to do this to be able to provide the correct HTML attributes without excessive repetition.
For example, given this form:
And this field component:
I want to be able to provide the
required,maxLength, etc attributes to the<input>element, but without needing to pass them to the component rendering as well as when constructing the validator. Instead I'd like to have some way to infer these from the form itself - from eitheruseFieldContextoruseFormContext.Is there any way to achieve this?
Cheers
Beta Was this translation helpful? Give feedback.
All reactions