2022-06-17 17:51:59 +02:00
|
|
|
<?php
|
|
|
|
|
2023-04-14 16:34:06 +02:00
|
|
|
use Kirby\Field\FieldOptions;
|
2025-07-04 15:08:52 +02:00
|
|
|
use Kirby\Toolkit\I18n;
|
2023-04-14 16:34:06 +02:00
|
|
|
|
2022-06-17 17:51:59 +02:00
|
|
|
return [
|
2022-08-31 15:02:43 +02:00
|
|
|
'extends' => 'radio',
|
|
|
|
'props' => [
|
|
|
|
/**
|
|
|
|
* Unset inherited props
|
|
|
|
*/
|
|
|
|
'columns' => null,
|
2022-06-17 17:51:59 +02:00
|
|
|
|
2022-08-31 15:02:43 +02:00
|
|
|
/**
|
|
|
|
* Custom icon to replace the arrow down.
|
|
|
|
*/
|
2025-04-21 18:57:21 +02:00
|
|
|
'icon' => function (string|null $icon = null) {
|
2022-08-31 15:02:43 +02:00
|
|
|
return $icon;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Custom placeholder string for empty option.
|
|
|
|
*/
|
2025-07-04 15:08:52 +02:00
|
|
|
'placeholder' => function (string|array $placeholder = '—') {
|
|
|
|
return I18n::translate($placeholder, $placeholder);
|
2022-08-31 15:02:43 +02:00
|
|
|
},
|
2023-04-14 16:34:06 +02:00
|
|
|
],
|
|
|
|
'methods' => [
|
|
|
|
'getOptions' => function () {
|
|
|
|
$props = FieldOptions::polyfill($this->props);
|
|
|
|
|
|
|
|
// disable safe mode as the select field does not
|
|
|
|
// render HTML for the option text
|
|
|
|
$options = FieldOptions::factory($props['options'], false);
|
|
|
|
|
|
|
|
return $options->render($this->model());
|
|
|
|
}
|
2022-08-31 15:02:43 +02:00
|
|
|
]
|
2022-06-17 17:51:59 +02:00
|
|
|
];
|