React Form Package
Edit page
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 to
onFocus
onBlur
onChange
*/}
</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 TypeRequiredDefaultDescription
id Stringtrue
typeStringtruecheckbox, date, textarea, datetime-local, email, number, tel, text, password, time, url, file
requiredBoolfalsefalse
minStringfalsetext, textarea, password: has to have at least min characters; number, date: has to be at least min
maxStringfalsetext, textarea, password: has to have at least min characters; number, date: has to be at least min
matchRegExfalsethe input value has to match the regular expression
sameAsString the input value has to have the same value as the input field with the id specified in sameAs
preOnChangeFunc false manipulate the state before its validated (see State Manipulation)
errorMessageStringfalsedefine 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 TypeRequiredDefaultDescription
onFocusFuncfalsepass your value to this function to update the state of the <Form /> component
onChangeFuncfalsepass your value to this function to update the state of the <Form /> component
onBlurFuncfalsepass your value to this function to update the state of the <Form /> component
metaObjectfalseget access to the state of the <FieldWrapper /> component (see State)