2022-06-17 17:51:59 +02:00
|
|
|
<?php
|
|
|
|
|
2022-12-19 14:56:05 +01:00
|
|
|
use Kirby\Toolkit\Str;
|
2025-04-21 18:57:21 +02:00
|
|
|
use Kirby\Toolkit\V;
|
2022-12-19 14:56:05 +01:00
|
|
|
|
2022-06-17 17:51:59 +02:00
|
|
|
return [
|
2022-08-31 15:02:43 +02:00
|
|
|
'extends' => 'tags',
|
|
|
|
'props' => [
|
|
|
|
/**
|
2025-04-21 18:57:21 +02:00
|
|
|
* If set to `all`, any type of input is accepted. If set to `options` only the predefined options are accepted as input.
|
2022-08-31 15:02:43 +02:00
|
|
|
*/
|
2025-04-21 18:57:21 +02:00
|
|
|
'accept' => function ($value = 'options') {
|
|
|
|
return V::in($value, ['all', 'options']) ? $value : 'all';
|
|
|
|
},
|
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 $icon = 'checklist') {
|
2022-08-31 15:02:43 +02:00
|
|
|
return $icon;
|
|
|
|
},
|
2022-12-19 14:56:05 +01:00
|
|
|
],
|
|
|
|
'methods' => [
|
|
|
|
'toValues' => function ($value) {
|
|
|
|
if (is_null($value) === true) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_array($value) === false) {
|
|
|
|
$value = Str::split($value, $this->separator());
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->sanitizeOptions($value);
|
|
|
|
}
|
|
|
|
],
|
2022-06-17 17:51:59 +02:00
|
|
|
];
|