SchemaInput
Renders one form field by resolving its schema to a concrete input component.
This is the component the generated forms mount. Reach for a specific input only when you build a form by hand or override one field.
Example
<SchemaInput
schema={productSchema.fields.price}
source="price"
/>
Props
| Name | Type | Default | Description |
|---|---|---|---|
schema (required) | FieldSchema | — | Field schema; drives which input is rendered |
source | string | schema.name | Name of the field in the form record |
label | string | ReactElement | false | schema.label | false hides the label |
helperText | string | ReactElement | false | schema.helpText | Text under the input |
readOnly | boolean | from the view | Renders the value read-only instead of an input |
showLabel | boolean | true | Renders the label |
defaultValue | string | boolean | number | — | Currently has no effect — the value is not forwarded to the input. Create-form defaults come from the form itself, which collects every schema.defaultValue into its default values |
disabled | boolean | false | Disables the input while keeping it in the form |
record | RaRecord | record from context | Renders a record other than the one in context |
onChange | () => void | — | Called after the value changes |
hiddenEl | ReactElement | — | Rendered in place of the input when dynamicRender.showQuery hides it |
What it does
- Picks read-only or editable content — a read-only field renders through the field components, not the inputs.
- Asks the active InputProvider for a component matching
schema.typeandschema.format;defaultInputProvideris the fallback. - Evaluates
options.dynamicRenderagainst the form's current values:showQueryhides the input (renderinghiddenElin its place) andrequiredQuerymakes it required. Inside a schema layout the layout hides the input instead, so the space it takes goes with it: a detail row drops its label too, a datagrid cell stays and only its content goes. - Attaches the field's validators:
required()when the schema says so, plus one validator per rule inoptions.validators, resolved through the validator provider.
Schema mapping
The dispatch table below is defaultInputProvider. format wins over type.
type | format | Input |
|---|---|---|
boolean | — | BooleanInput, or TriStateBooleanInput in a filter |
number | — | NumberInput (2–5 fraction digits) |
integer | — | NumberInput (0 fraction digits) |
integer / string | relation, tree-relation | SchemaReferenceInput |
integer / string | choices | ChoicesInput |
string | — | TextInput |
string | text | TextInput (multiline) |
string | email, url, password | TextInput with the matching HTML input type |
string | date / date-time / time | DateInput / DateTimeInput, TimeInput |
string | rich-text | RichTextInput from ra-input-rich-text |
string | decimal | NumberInput |
string | phone | PhoneNumberInput |
string | search | React Admin SearchInput |
string | ai, ai-text | SchemaPredictiveTextInput |
string | czech-* | Czech local flavor inputs |
object | base64-image | UploadInput with an image preview, maxFiles: 1 |
object | base64-file | UploadInput, maxFiles: 1 |
object | range | DateRangeInput when both bounds are dates, otherwise SchemaRangeInput |
object | — (with properties) | SchemaObjectInput |
array | items base64-image / base64-file | UploadInput in multi-file mode |
array | items of type object | SchemaObjectArrayInput |
array | — | SchemaArrayInput |
tip
A field that renders no input usually has a schema the provider cannot resolve — an object
without properties, or an array without items.
See also
- InputProvider — overriding the mapping above
- SchemaField — the same dispatch for display
- FieldSchema — the schema this component consumes