julienmonnerie/kirby/config/fields/select.php

38 lines
730 B
PHP
Raw Normal View History

2022-06-17 17:51:59 +02:00
<?php
2023-04-14 16:34:06 +02:00
use Kirby\Field\FieldOptions;
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.
*/
'icon' => function (string $icon = null) {
return $icon;
},
/**
* Custom placeholder string for empty option.
*/
'placeholder' => function (string $placeholder = '—') {
return $placeholder;
},
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
];