Select
The select control has a wide range of customization options. The select control can be configured to allow for single or multiple selections, as well as the ability to search for options.
The select control saves both the value
and label
of the selected option. For example:
Will return an array:
Select Example
Options
Options support a combination of standard options and optgroups. Standard options should contain a value
and a label
key. Optgroups should be an array of objects with label
and options
keys as shown in the example above.
Endpoint
The endpoint value should be relative to the WordPress REST API URL. The full domain does not need to be provided. E.g, setting the endpoint to:
Will fetch the options from:
If an endpoint
key is present, it will be merged with the options
and the additional options will be fetched from the specified URL. The endpoint should return a JSON array of objects with value
and label
keys. Endpoints can also return an object of optgroups with label
and options
keys. E.g.:
dynamicSearch
The search control allows the user to perform a search from a REST API endpoint.
Search
When dynamicSearch
is enabled, the select control passes the typed characters to the endpoint as a query parameter. The query parameter is named search
. E.g.:
Response
Endpoints should return a JSON array of objects with value
and label
keys. Endpoints can also return an object of optgroups with label
and options
keys. E.g.: