Form is a controller for input fields
## Usage - use `Form` to wrap inputs within it - use `FormTextField`, `FormSwitch` components , these components are enabled to work with in the form - use `withResetButton` and `withSubmitButton` helpers to add reset and submit buttons ```typescript import { Form, FormProps, FormTextField, FormSwitch, withSubmitButton } from "mui-extended"; import { TextField, Button } from "@mui/material"; const formProps: FormProps; const ResetButton = withResetButton(Button); const SubmitButton = withSubmitButton(Button); const form = ( <Form {...formProps}> <FormTextField name="username" /> <FormSwitch name="remember" InputProps={{ formControlLabelProps: { label: "Remember Me", labelPlacement: "end" } }} /> <ResetButton>Reset</ResetButton> <SubmitButton>Submit</SubmitButton> </Form> );
JSON Schema
Initializes and manages FormContext
Props
initialValues
initialErrors
onSubmit
schemas
validators
(name: string, value: unknown) => Promise<void>
use
useFormContext
value contains
values
touched
errors
isDirty
isValid
isSubmitting
onFieldChange
(name: string, value: unknown) => void
onFieldBlur
(name: string) => void
submit
reset
Following props of any Input component are used to control Input with in the Form.
name
value
onChange
onFieldChange
onBlur
onFieldBlur
label
error
helperText
disabled
withFormField
The default Input components provided by
material-ui
withFormField
Specific wrapper components are created for each Input from
material-ui
All Wrapper Components are described here
This is not a FormAutocomplete
label is auto generated from name
label is auto generated from name
{}
Write an email to opensource@sodaru.com