useFormField
Use the form field's state for advanced composition with custom form components.
You can use useFormField
within the context of a Field, Fieldset, or ElementField component to access the state of the field and use it to build more advanced form components.
Usage Example
The useFormField
function is provided for more advanced use cases where you may need to access the entire state of a form field, as well as the form itself.
In the example above, we're using the useFormField
function to pass a custom errorsId
that will be used to apply appropriate ARIA attributes to the other components within the field.
API
Props
Optionally provide a getter function that returns a custom ID to override the errors container ID.
Optionally provide a getter function that returns a custom ID to override the description container ID.
Return Type
useFormField
returns the following type:
Warning
The useFormField
function returns getters for the various reactive states. You should not destructure the object returned by useFormField
and instead use the getters directly.