IntroductionInstallationFormSimple FormButtonFieldFieldWrapperBasic UsagePropsProps that get exposed to the child componentRadioGroupSelectForm ValidationStateonFocus onChange onBlurState ManipulationCustom Error MessagesFeedback on disabled ButtonStylingDynamic FieldsDynamic Fields 2Dynamic Fields 3Bind Input FieldsBind Input Fields 2Third Party ComponentsFile UploadWhy
FieldWrapper
This component is here for edge cases where you get the state from another component and you have to pass it to the
<Form />
component manually, e.g. third party components.
This component has to be a child within the <Form />
component. This component exposes three additional props to its child component so that you are able to use third party components.
Basic Usage
import {Form,FieldWrapper,} from 'react-form-package';
Render a <Form />
with an <FieldWrapper />
and a <Button />
component.
Take a look into the Third Party Components Section to see how you can use this component properly.
<Form><div><FieldWrapper type="text" id="fieldwrapper">{/*Render a child component that gets access toonFocusonBluronChange*/}</FieldWrapper><div><Button id="submit" type="submit" onClick={(state) => {alert(JSON.stringify(state, null, 2));alert('open the console to see the whole state...');console.log(state);}}>Submit</Button></div></Form>
Props
Property | Type | Required | Default | Description |
---|---|---|---|---|
id | String | true | ||
type | String | true | checkbox , date , textarea , datetime-local , email , number , tel , text , password , time , url , file | |
required | Bool | false | false | |
min | String | false | text , textarea , password : has to have at least min characters; number , date : has to be at least min | |
max | String | false | text , textarea , password : has to have at least min characters; number , date : has to be at least min | |
match | RegEx | false | the input value has to match the regular expression | |
sameAs | String | the input value has to have the same value as the input field with the id specified in sameAs | ||
preOnChange | Func | false | manipulate the state before its validated (see State Manipulation) | |
errorMessage | String | false | define your own custom error message for the input |
Props that get exposed to the child component
To see how you can use this properties take a look at Third Party Components
Property | Type | Required | Default | Description |
---|---|---|---|---|
onFocus | Func | false | pass your value to this function to update the state of the <Form /> component | |
onChange | Func | false | pass your value to this function to update the state of the <Form /> component | |
onBlur | Func | false | pass your value to this function to update the state of the <Form /> component | |
meta | Object | false | get access to the state of the <FieldWrapper /> component (see State) |