Skip to content

Allow JSON registration of custom ArrayTemplateField and ObjectTemplateField #1680

@timkindberg

Description

@timkindberg

Prerequisites

  • I have read the documentation;
  • In the case of a bug report, I understand that providing a SSCCE example is tremendously useful to the maintainers.

Description

Currently custom ArrayTemplateField and ObjectTemplateField components must be set via a function reference. This means you cannot use them in plain JSON.

Expected behavior

I'd like to register these like I do custom widgets/fields.

const table = (props) => { ...a component that renders a <table> with rows... };

const templateFields = { table };

const uiSchema = {
  "ui:ArrayTemplateField": "table"
}

render((
  <Form
    schema={schema}
    uiSchema={uiSchema}
    templateFields={templateFields} />
), document.getElementById("app"));

Actual behavior

Not possible, you must do this:

const table = (props) => { ...a component that renders a <table> with rows... };

const uiSchema = {
  "ui:ArrayFieldTemplate": table  // HAVE TO USE FUNCTION REFERENCE
}

render((
  <Form
    schema={schema}
    uiSchema={uiSchema} />
), document.getElementById("app"));

Version

1.8.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions