Interface IFormComponentProps<T>

FormComponent properties

interface IFormComponentProps<T> {
    _internalFormWrapper?: ElementType;
    acceptcharset?: string;
    action?: string;
    autoComplete?: string;
    buttonStyle?: "text" | "icons";
    children?: ReactNode;
    className?: string;
    compact?: boolean;
    customValidate?: CustomValidator<T, RJSFSchema, any>;
    disabled?: boolean;
    enctype?: string;
    experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior;
    extraErrors?: ErrorSchema<T>;
    extraErrorsBlockSubmit?: boolean;
    fields?: RegistryFieldsType<T, RJSFSchema, any>;
    focusOnFirstError?: boolean | ((error) => void);
    formContext?: unknown;
    formData: T;
    id?: string;
    idPrefix?: string;
    idSeparator?: string;
    liveOmit?: boolean;
    liveValidate?: boolean;
    method?: string;
    name?: string;
    noHtml5Validate?: boolean;
    noValidate?: boolean;
    omitExtraData?: boolean;
    onBlur?: ((id, data) => void);
    onChange: ((e) => any);
    onError?: ((errors) => void);
    onFocus?: ((id, data) => void);
    onSubmit?: ((data, event) => void);
    readonly?: boolean;
    ref?: Ref<default<T, RJSFSchema, any>>;
    schema: RJSFSchema;
    showErrorList?: false | "top" | "bottom";
    showModifiedFromDefault?: boolean;
    tagName?: ElementType;
    target?: string;
    templates?: Partial<Omit<TemplatesType<T, RJSFSchema, any>, "ButtonTemplates">> & {
        ButtonTemplates?: Partial<{
            AddButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
            CopyButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
            MoveDownButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
            MoveUpButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
            RemoveButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
            SubmitButton: ComponentType<SubmitButtonProps<T, RJSFSchema, any>>;
        }>;
    };
    transformErrors?: ErrorTransformer<T, RJSFSchema, any>;
    translateString?: ((stringKey, params?) => string);
    translator?: ITranslator;
    uiSchema?: UiSchema<T, RJSFSchema, any>;
    validator: ValidatorType<T, RJSFSchema, any>;
    widgets?: RegistryWidgetsType<T, RJSFSchema, any>;
}

Type Parameters

Hierarchy (view full)

Properties

_internalFormWrapper?: ElementType

_internalFormWrapper is currently used by the semantic-ui theme to provide a custom wrapper around <Form /> that supports the proper rendering of those themes. To use this prop, one must pass a component that takes two props: children and as. That component, at minimum, should render the children inside of a

tag unless as is provided, in which case, use the as prop in place of <form />. i.e.:

export default function InternalForm({ children, as }) {
const FormTag = as || 'form';
return <FormTag>{children}</FormTag>;
}

Use at your own risk as this prop is private and may change at any time without notice.

acceptcharset?: string

The value of this prop will be passed to the accept-charset HTML attribute on the form

action?: string

The value of this prop will be passed to the action HTML attribute on the form

NOTE: this just renders the action attribute in the HTML markup. There is no real network request being sent to this action on submit. Instead, react-jsonschema-form catches the submit event with event.preventDefault() and then calls the onSubmit function, where you could send a request programmatically with fetch or similar.

autoComplete?: string

The value of this prop will be passed to the autocomplete HTML attribute on the form

buttonStyle?: "text" | "icons"

Button style.

children?: ReactNode

The optional children for the form, if provided, it will replace the default SubmitButton

className?: string

The value of this prop will be passed to the class HTML attribute on the form

compact?: boolean

Whether the container is in compact mode or not. In compact mode the title and description are displayed more compactness.

customValidate?: CustomValidator<T, RJSFSchema, any>

Formerly the validate prop; Takes a function that specifies custom validation rules for the form

disabled?: boolean

It's possible to disable the whole form by setting the disabled prop. The disabled prop is then forwarded down to each field of the form. If you just want to disable some fields, see the ui:disabled parameter in uiSchema

enctype?: string

The value of this prop will be passed to the enctype HTML attribute on the form

experimental_defaultFormStateBehavior?: Experimental_DefaultFormStateBehavior

Optional configuration object with flags, if provided, allows users to override default form state behavior Currently only affecting minItems on array fields and handling of setting defaults based on the value of emptyObjectFields

extraErrors?: ErrorSchema<T>

This prop allows passing in custom errors that are augmented with the existing JSON Schema errors on the form; it can be used to implement asynchronous validation. By default, these are non-blocking errors, meaning that you can still submit the form when these are the only errors displayed to the user.

extraErrorsBlockSubmit?: boolean

If set to true, causes the extraErrors to become blocking when the form is submitted

fields?: RegistryFieldsType<T, RJSFSchema, any>

The dictionary of registered fields in the form

focusOnFirstError?: boolean | ((error) => void)

If set to true, then the first field with an error will receive the focus when the form is submitted with errors

Type declaration

    • (error): void
    • Parameters

      • error: RJSFValidationError

      Returns void

formContext?: unknown
formData: T
id?: string

The value of this prop will be passed to the id HTML attribute on the form

idPrefix?: string

To avoid collisions with existing ids in the DOM, it is possible to change the prefix used for ids; Default is root

idSeparator?: string

To avoid using a path separator that is present in field names, it is possible to change the separator used for ids (Default is _)

liveOmit?: boolean

If omitExtraData and liveOmit are both set to true, then extra form data values that are not in any form field will be removed whenever onChange is called. Set to false by default

liveValidate?: boolean

If set to true, the form will perform validation and show any validation errors whenever the form data is changed, rather than just on submit

method?: string

The value of this prop will be passed to the method HTML attribute on the form

name?: string

The value of this prop will be passed to the name HTML attribute on the form

noHtml5Validate?: boolean

If set to true, turns off HTML5 validation on the form; Set to false by default

noValidate?: boolean

If set to true, turns off all validation. Set to false by default

Deprecated

  • In a future release, this switch may be replaced by making validator prop optional
omitExtraData?: boolean

If set to true, then extra form data values that are not in any form field will be removed whenever onSubmit is called. Set to false by default.

onBlur?: ((id, data) => void)

Sometimes you may want to trigger events or modify external state when a field has been touched, so you can pass an onBlur handler, which will receive the id of the input that was blurred and the field value

Type declaration

    • (id, data): void
    • Parameters

      • id: string
      • data: any

      Returns void

onChange: ((e) => any)

Type declaration

    • (e): any
    • Parameters

      • e: IChangeEvent<T, RJSFSchema, any>

      Returns any

onError?: ((errors) => void)

To react when submitted form data are invalid, pass an onError handler. It will be passed the list of encountered errors

Type declaration

    • (errors): void
    • Parameters

      • errors: RJSFValidationError[]

      Returns void

onFocus?: ((id, data) => void)

Sometimes you may want to trigger events or modify external state when a field has been focused, so you can pass an onFocus handler, which will receive the id of the input that is focused and the field value

Type declaration

    • (id, data): void
    • Parameters

      • id: string
      • data: any

      Returns void

onSubmit?: ((data, event) => void)

You can pass a function as the onSubmit prop of your Form component to listen to when the form is submitted and its data are valid. It will be passed a result object having a formData attribute, which is the valid form data you're usually after. The original event will also be passed as a second parameter

Type declaration

    • (data, event): void
    • Parameters

      • data: IChangeEvent<T, RJSFSchema, any>
      • event: FormEvent<any>

      Returns void

readonly?: boolean

It's possible to make the whole form read-only by setting the readonly prop. The readonly prop is then forwarded down to each field of the form. If you just want to make some fields read-only, see the ui:readonly parameter in uiSchema

ref?: Ref<default<T, RJSFSchema, any>>

Support receiving a React ref to the Form

schema: RJSFSchema

The JSON schema object for the form

showErrorList?: false | "top" | "bottom"

When this prop is set to top or 'bottom', a list of errors (or the custom error list defined in the ErrorList) will also show. When set to false, only inline input validation errors will be shown. Set to top by default

showModifiedFromDefault?: boolean

Whether to display if the current value is not the default one.

tagName?: ElementType

It's possible to change the default form tag name to a different HTML tag, which can be helpful if you are nesting forms. However, native browser form behaviour, such as submitting when the Enter key is pressed, may no longer work

target?: string

The value of this prop will be passed to the target HTML attribute on the form

templates?: Partial<Omit<TemplatesType<T, RJSFSchema, any>, "ButtonTemplates">> & {
    ButtonTemplates?: Partial<{
        AddButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        CopyButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        MoveDownButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        MoveUpButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        RemoveButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        SubmitButton: ComponentType<SubmitButtonProps<T, RJSFSchema, any>>;
    }>;
}

The dictionary of registered templates in the form; Partial allows a subset to be provided beyond the defaults

Type declaration

  • Optional ButtonTemplates?: Partial<{
        AddButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        CopyButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        MoveDownButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        MoveUpButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        RemoveButton: ComponentType<IconButtonProps<T, RJSFSchema, any>>;
        SubmitButton: ComponentType<SubmitButtonProps<T, RJSFSchema, any>>;
    }>
transformErrors?: ErrorTransformer<T, RJSFSchema, any>

A function can be passed to this prop in order to make modifications to the default errors resulting from JSON Schema validation

translateString?: ((stringKey, params?) => string)

Optional string translation function, if provided, allows users to change the translation of the RJSF internal strings. Some strings contain replaceable parameter values as indicated by %1, %2, etc. The number after the % indicates the order of the parameter. The ordering of parameters is important because some languages may choose to put the second parameter before the first in its translation.

Type declaration

    • (stringKey, params?): string
    • Parameters

      • stringKey: TranslatableString
      • Optional params: string[]

      Returns string

translator?: ITranslator

Translator for button text.

uiSchema?: UiSchema<T, RJSFSchema, any>

The uiSchema for the form

validator: ValidatorType<T, RJSFSchema, any>

An implementation of the ValidatorType interface that is needed for form validation to work

widgets?: RegistryWidgetsType<T, RJSFSchema, any>

The dictionary of registered widgets in the form