-
Notifications
You must be signed in to change notification settings - Fork 3
Reference
Jørgen Landsnes edited this page Mar 7, 2018
·
1 revision
This component keeps track of the form's data by initializing a named store.
Props:
-
initialStatefor form pre-population (object) -
store[required]is the name of the store (string) -
classNamefor the form (string/defaultform) -
childrenis the form elements (node) -
onSubmit(storeObject, handleFinishSubmit)is called on submit after a successful validation (function) -
submitButtonTextis the name for submit button (text/defaultOK) -
submitButtonClassName(string/defaultbutton button__primary) -
centerSubmitButtonadds a class for centering the submit button (boolean/defaulttrue, class nameform__button-container--center) -
noSubmitButtonif you don't want buttons for some reason (boolean) -
spinneris an optional react component to show on the submit button during submit (object) -
submittingTextis used if no spinner is presence. (string/default...) -
scrollDurationis the duration of the animation to a field with an error (number/default400ms) -
wizardStepif the form is a wizard, important for unsubscribing event (boolean) -
backButton[automatic with wizard](object)
Wraps the form with functionality for a multistep form.
Props:
-
stepsis an array containing all the steps for the wizard on the format[{title: 'Header step 1', component: <FirstStep />, initialState: { secondstep: 't2' }[optional]}, ... ] -
storeis the name of the store (string) -
classNamefor the wizard (string/defaultwizard) -
goBackis called on back button click, used if you want something more than just the previous step (function/default go to previous step) -
goNextis called on next click, used if you want something more than just the next step (function/default go to next step if not the last step) -progressIndicator(currentStepNo, numberOfSteps)if your form requires a progressIndicator (function) -
backButtonClassName(string/defaultbutton button__back) -
backButtonTextis displayed on the back button (string/defaultBack) - `handleFinish(formData)[required] is called on the last step (function)
-
receipt(wizardData)can display a receipt after submit (function)
The Field component is a wrapper for all the different form input types.
Props:
-
typeis the type of the field. One of hidden|radio|textarea|select|checkbox|text|date (string/defaulttext) -
name[required]is an unique name used for the key in the store (string) -
labelis the label for the field (string) -
valuecould be either a string for e.g. text inputs, an array for e.g. multiple selects or a boolean for checkbox (boolean|array|string) -
disabledwhether the field is disabled or not (boolean) -
requiredwhether the field is required or not (boolean) -
deleteOnUnmountSome forms may have sections that are only available based on values of other fields in the form, such as "Show advanced options", followed by conditional input fields. Such inputs should only appear in the store if they are visible, and because they are initiated upon mount, this option allows for them to delete the value in the store upon unmount (boolean) -
validateis used for validation of the field format, and could be either the name of a validator function from the validation library, or a custom function. (string|function) -
dependOnis used by fields that depends on other fields and is the name of this other field (string) -
dependencyFuncis a function called by the field that is dependent on some other field as declared independOnupon change (function) -
dateParseris used if you need on the fly date format parsing in your date input field (function) -
onChangeoptional function called on value change (function) -
multipleindicating multiple simultaneous selections (boolean/applies toselect|checkbox) -
optionsfor input elements with options, either on the format[{label: 'Option 1', value: 'one', disabled[optionally]: true}]or[{'Option 1'}, {'Option 2'}](array) -
maxLengthis the max number of chars (number) -
placeholderis a text to show as placeholder string (string) -
labelIdis an id for a label (string) -
errorTextis showed when validation fails (string) -
requiredMarktext or symbol to mark a field as required (string/default*)