-
Notifications
You must be signed in to change notification settings - Fork 5
select
Stefano Iachetta edited this page Apr 12, 2022
·
4 revisions
{
"id": "select",
"type": "select",
"size": "half",
"label": "label",
"description": "description",
"required": true,
"multiple": true,
"options": [
{
"label": "label1",
"value": "value1"
},
{
"label": "label2",
"value": "value2"
}
],
}
The select field makes the user choose between its options.
For the general settings fields, check the getting started page.
The select field has several additional settings:
-
"multiple"
defines whether the user can select just one or multiple options. -
"options"
contains the options from which the user is able to choose. Each option has two fields:-
"label"
contains the text displayed in the UI. -
"value"
contains the value that gets saved to the database.
-
You can filter the field's fetched value by calling WordPress' add_filter with the tag "aeria_get_select"
.
{
"type": "select",
"id": "input-selectmultiple-ajax",
"label" : "input-selectmultiple-ajax",
"description": "description",
"multiple": true,
"dependsOn": {
"id": "input-relation",
"key": "post-id"
},
"ajax": {
"post_type": "book",
"endpoint": "/wp-json/aeria/search",
"appendValueToEndpoint": false
},
"size": "half",
"required": true
}
The AJAX select is a special select field: instead of having an array of values, it fetches them from an API.
For the general settings fields, check the getting started page.
The select field has several additional settings:
-
"multiple"
defines whether the user can select just one or multiple options. -
"ajax"
, containing the options for the ajax call:-
"endpoint"
defines the url to call. The default value is"/wp-json/aeria/search"
- any other key/value that you want to pass to the endpoint (es. "post_type": "book" to only get the book posts)
-
-
"dependsOn"
defines a related field that you want to use to get a parameter for the ajax call and accepts:-
"id"
is the field id -
"key"
is the key to use in the ajax call -
"appendValueToEndpoint"
iftrue
append value of this field dynamically onchange
to"endpoint"
-
You can filter the field's fetched value by calling WordPress' add_filter with the tag "aeria_get_select"
.