The currency input widget allows to input a currency value.
agent.customizeCollection('product', collection => {collection.addAction('Change price', { scope:'Single', form: [ { label:'Price', type:'Number', widget:'CurrencyInput', placeholder:'Enter the new price', isRequired:true, min:0, max:1000, step:1, currency:'USD', base:'Unit', }, ],execute:async context => {/* ... perform work here ... */ }, });});
The above code will produce the following form:
Options
DatePicker widget
The date picker widget allows to input a date in a form
agent.customizeCollection('order', collection => {collection.addAction('Set shipping date', { scope:'Single', form: [ { label:'Shipping date', type:'Date', widget:'DatePicker', format:'DD-MM-YYYY', min:newDate(Date.now() -10*24*60*60*1000), max:newDate(), placeholder:'please indicate when you shipped the item', }, ],execute:async context => {/* ... perform work here ... */ }, });});
The above code will produce the following form :
Note: using a Dateonly field type will hide the time section from the date picker
Options
The dates are sent as ISO 8601 formatted strings over the network. In order to use them as Date object in your hooks, you can parse them directly like so
In this next example, we call a remote api to get a list of products and then perform a custom filter based on given fields of the json response, and return the first 25. This example uses search: 'dynamic' dropdown widget, which provides you with the searchValue in the callback context.
Note: when a search is performed, only the field on which it is performed will have its options recomputed.
Using the options function, you can dynamically change the list of options based on the context, which contains information about the selected records and other values in the form. More info about dynamic configuration.
Rich text widget
The rich text widget allows to input a formatted text value.
agent.customizeCollection('product', collection => {collection.addAction('Leave a review', { scope:'Single', form: [ { label:'Comment', type:'String', widget:'RichText', isRequired:true, placeholder:'Type your comment here', }, ],execute:async context => {/* ... perform work here ... */ }, });});
The above code will produce the following form:
Options
Text area widget
The text area widget allows to input a multiline string value.
agent.customizeCollection('product', collection => {collection.addAction('Leave a review', { scope:'Single', form: [ { label:'Comment', type:'String', widget:'TextArea', isRequired:true, placeholder:'Type your comment here...', rows:10, }, ],execute:async context => {/* ... perform work here ... */ }, });});
The above code will produce the following form:
Options
Text input widget
The text input widget allows to input a string value.
agent.customizeCollection('customer', collection => {collection.addAction('Send notification', { scope:'Single', form: [ { label:'Message', type:'String', widget:'TextInput', placeholder:'Enter your message here', }, ],execute:async context => {/* ... perform work here ... */ }, });});
The above code will produce the following form:
Options
Text input list widget
The text input list widget allows to input a list of string values.