AutoField algorithm

let component = props.component;
if (component === undefined) {
if (props.allowedValues) {
if (props.checkboxes && props.fieldType !== Array) {
component = RadioField;
} else {
component = SelectField;
} else {
switch (props.fieldType) {
case Date:
component = DateField;
case Array:
component = ListField;
case Number:
component = NumField;
case Object:
component = NestField;
case String:
component = TextField;
case Boolean:
component = BoolField;
invariant(component, 'Unsupported field type: %s', props.fieldType.toString());

Guaranteed props

Note: These are not the only props that a field will receive - these are guaranteed for all fields created with connectField helper.

changedboolHas field changed?
disabledboolIs field disabled?
errorobjectField scoped part of validation error.
errorMessagestringField scoped validation error message.
fieldobjectField definition from schema.
fieldsarrayOf(string)Subfields names.
fieldTypefuncField type.
findErrorfunc(name)Request another field error.
findFieldfunc(name)Request another field field.
findValuefunc(name)Request another field value.
idstringField id - given or random.
labelstringField label.
namestringField name.
onChangefunc(value, [name])Change field value.
parentobjectParent field props.
placeholderstringField placeholder.
valueanyField value.

Props propagation

Few props propagate in a very special way. These are label, placeholder and disabled.


<TextField /> // default label | no placeholder
<TextField label="Text" /> // custom label | no placeholder
<TextField label={false} /> // no label | no placeholder
<TextField placeholder /> // default label | default placeholder
<TextField placeholder="Text" /> // default label | custom placeholder
<NestField label={null}> // null = no label but the children have their labels
<TextField />
<NestField label={false}> // false = no label and the children have no labels
<TextField />
<ListField name="authors" disabled> // Additions are disabled...
<ListItemField name="$" disabled> // ...deletion too
<NestField disabled={false} name=""> // ...but editing is not.
<TextField name="name" />
<NumField name="age" />

Note: label, placeholder and disabled are cast to Boolean before being passed to nested fields.