julienmonnerie/kirby/config/fields/multiselect.php

48 lines
926 B
PHP
Raw Normal View History

2022-06-17 17:51:59 +02:00
<?php
2022-12-19 14:56:05 +01:00
use Kirby\Toolkit\Str;
2022-06-17 17:51:59 +02:00
return [
2022-08-31 15:02:43 +02:00
'extends' => 'tags',
'props' => [
/**
* Unset inherited props
*/
'accept' => null,
/**
* Custom icon to replace the arrow down.
*/
'icon' => function (string $icon = null) {
return $icon;
},
/**
* Enable/disable the search in the dropdown
* Also limit displayed items (display: 20)
* and set minimum number of characters to search (min: 3)
*/
'search' => function ($search = true) {
return $search;
},
/**
* If `true`, selected entries will be sorted
* according to their position in the dropdown
*/
'sort' => function (bool $sort = false) {
return $sort;
},
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
];