Custom Form Inputs
You can define custom Angular or React components which can be used to render Custom Fields you have defined on your entities as well as configurable args used by custom Configurable Operations.
For Custom Fields
Let's say you define a custom "intensity" field on the Product entity:
By default, the "intensity" field will be displayed as a number input:
But let's say we want to display a range slider instead.
1. Define a component
First we need to define a new Angular or React component to render the slider:
Angular components will have the readonly, config and formControl properties populated automatically.
2. Register the component
Next we will register this component in our providers.ts file and give it a unique ID, 'slider-form-input':
3. Register the providers
The providers.ts is then passed to the compileUiExtensions() function as described in the UI Extensions Getting Started guide:
4. Update the custom field config
Once registered, this new slider input can be used in our custom field config:
As we can see, adding the ui property to the custom field config allows us to specify our custom slider component.
The component id 'slider-form-input' must match the string passed as the first argument to registerFormInputComponent().
If we want, we can also pass any other arbitrary data in the ui object, which will then be available in our component as this.config.ui.myField. Note that only JSON-compatible data types are permitted, so no functions or class instances.
Re-compiling the Admin UI will result in our SliderControl now being used for the "intensity" custom field:
Custom Field Controls for Relations
If you have a custom field of the relation type (which allows you to relate entities with one another), you can also define custom field controls for them. The basic mechanism is exactly the same as with primitive custom field types (i.e. string, int etc.), but there are a couple of important points to know:
- The value of the
formControlwill be the related entity object rather than an id. The Admin UI will internally take care of converting the entity object into an ID when performing the create/update mutation. - Your control will most likely need to fetch data in order to display a list of selections for the user.
Here's an example of a custom field control for a relation field which relates a Product to a custom ProductReview entity:
For ConfigArgs
ConfigArgs are used by classes which extend Configurable Operations (such as ShippingCalculator or PaymentMethodHandler). These ConfigArgs allow user-input values to be passed to the operation's business logic.
They are configured in a very similar way to custom fields, and likewise can use custom form inputs by specifying the ui property.
Here's an example:

