Skip to content

feat: allow users to override attribute to component conversion

Allows users to specify what component they want to use depending on the attribute. This is useful when the auto-generation does not give satisfying results for some attributes and rewriting the views would be too much work.

The default generation is exported so users can create a simple function to change only a few attributes and keep the rest auto-generated. Here is an example to show an url field for the web attribute (auto-generation would use a text field):

<AutoConfigContextProvider
            initialConfig={{
              version: "",
              attributeToComponentOverrides: {
                field: (attribute) => {
                  // describe custom components
                  if (attribute.type === "web") {
                    return <UrlField source={attribute.type} />;
                  }
                  // Use the default auto-generation for the rest
                  return getFieldFromAttributeDefault(attribute);
                },
              },
            }}
          >

Depends on !67 (merged)

Closes #60 (closed)

Edited by Arnaud Vergnet

Merge request reports

Loading