You may already know that using data-*@
allows you to call functions on your blueprints.
Setting the options on a select field is as simple as doing data-options@
. However, trying to set the options of a Selectize field could be less obvious.
To do so, you need to set your function inside the selectize property: yourfield.selectize.data-options@
.
fields:
selectize:
type: selectize
selectize:
data-options@: \Grav\Plugin\YourPluginClass::myStaticFunction
And you must return a correctly formatted array, with each child having a value and text property.
public static function myStaticFunction(){
return [
[
'value' => 'real-value'
'text' => 'Option One'
],
[
'value' => 'real-value-two'
'text' => 'Option Two'
],
[
'value' => 'real-value-three'
'text' => 'Option Three'
],
];
}