Files
lichterei-web/kirby/config/fields/number.php
Bastian Allgeier 8e3d86a590 Upgrade to 3.0.2
2019-02-19 16:39:58 +01:00

47 lines
1.1 KiB
PHP
Executable File

<?php
return [
'props' => [
/**
* Default number that will be saved when a new Page/User/File is created
*/
'default' => function ($default = null) {
return $this->toNumber($default);
},
/**
* The lowest allowed number
*/
'min' => function (float $min = null) {
return $min;
},
/**
* The highest allowed number
*/
'max' => function (float $max = null) {
return $max;
},
/**
* Allowed incremental steps between numbers (i.e 0.5)
*/
'step' => function ($step = 1) {
return $this->toNumber($step);
},
'value' => function ($value = null) {
return $this->toNumber($value);
}
],
'methods' => [
'toNumber' => function ($value) {
if ($this->isEmpty($value) === true) {
return null;
}
return (float)Str::float($value);
}
],
'validations' => [
'min',
'max'
]
];