Custom Forms
Similar to lists, we can replace a generic EntryCreate / EntryEdit form with a custom Create / Edit View.
#
Custom EditHere's an example of a custom edit component:
To use it, we can override the edit prop on the target Resource:
#
Custom CreateImplementing a custom create form is similar to the above example:
To use it, we can override the create prop on the target Resource:
The implementation is quite similar to a custom Edit. The differences are:
- useFields is used with excludeSystemFields true (omits id, created, modified, creator).
- third param of inputProps is true (ignores readonly fields)
- uses Create instead of Edit
#
Used APIsThe examples use the following ec.admin APIs:
Note that the "name" field just uses a plain TextInput. When going that route, you have to make sure that the component can handle the field's value. The commented out version of it shows how the field would could be implemented without inputProps. If going that route, you have to check set props:
- source: field name (make sure it exists)
- options.disabled should be true if the field is readOnly
Of course, the component that is used for a field can also be custom. For more info see Writing Your Own Input Component.