$ npm install prop-types lodash react react-fractal-field --save
import { Field, FieldSet } from 'react-fractal-field';
const MyComponent = ({ onSubmit }) => (
<FieldSet onSubmit={onSubmit} isolated>
{({ triggerSubmit }) => (
<div>
<Field name="value">
{({ control }) => (
<div>
<input {...control} type="text" />
</div>
)}
</Field>
<button onClick={triggerSubmit}>Submit</button>
</div>
)}
</FieldSet>
)
id
: [ String, Number ] - ID used for remote controlling this field/form (null
by default)softTypes
: [ Boolean ] - disable type checking. HIGHLY NOT RECOMMENDED!isolated
: [ Boolean ] - if true meta/value stopped from sharing between parentname
: [ String, Number ] - need for value bindingvalue
: [String, Boolean, Number, Array, Object, Null]initialValue
: [String, Boolean, Number, Array, Object, Null] - values that will be provided for child fields (useful only for forms)onChange
: [ Function ] - handler that will be called on every field value changesonValueChange
: [ Function ] - handler that will be called on every field changesvalidate
: [ Function ] - validation function/array . if error it need to return the error-message stringonChangeValidity
: [ Function ]postponeInvalid
: [ Boolean ]form
: [ Boolean ]onSubmit
: [ Function ] - handler that will be called ontriggerSubmit
only in valid form stateexceptionMessage
: [ Any ] - error message in case validate/normalize/format throws the errorchildren
: [ Function ] - obviously, content of field/formautoClean
: [ Boolean ]debug
: [ Boolean ]
normalize
: [ Function ] - filter value before call onChange/onSubmit/validate callbackformat
: [ Function ] - filter value before rendering (or set value to child field). from outer format to inner format
triggerChange
: [ Function ] - call when you want to trigger change field by some casetriggerReset
: [ Function ] - call when you want to trigger submit, obviousvalue
: [ Any ]touched
: [ Boolean ] - true when field or some child field was changed oncepristine
: [ Boolean ] - true when field or some child field was not changed oncesubmitted
: [ Boolean ] - when this form/field of parent was submitted oncevalid
: [ Boolean ] - true if children and this field has no errorsinvalid
: [ Boolean ] - true if children and this field/children has errorshasException
: [ Boolean ] - true if children and this field/children has exceptionserror
: [ Any ] - first error are not false, that returned from validate functioninvalidChildren
: [ Array ] - ids of closest children with errorsactive
: [ Boolean ] - true if field/children is focusing right nowactivated
: [ Boolean ] - true if field/children was focused onceform
: [ Object ] - Props of closest isolated form (or field itself)
triggerSubmit
: [ Function ] - call when you want to trigger submit, obvioussubmitSuccess
: [ Boolean ] - state of submittingsubmitFailed
: [ Boolean ] - state of submittingsubmitting
: [ Boolean ] - state of submit processing. in pending (if onSubmit returns the Promise object)submitted
: [ Boolean ] - true if form was submitted oncesubmittedTimes
: [ Number ] - count oftriggerSubmit
callingsubmitErrors
- Any - payload of submitting
control: { value, onChange, onBlur, onFocus }
- shortcut for putting it into control component (only for components without children fractal-fields)
removeItems
: [ Function ]appendItems
: [ Function ]prependItems
: [ Function ]items
: [ Array ]
triggerSubmit(id)
triggerChange(id)
onError(callback)