Upgrade to 3.2.5

This commit is contained in:
Bastian Allgeier
2019-09-24 11:00:59 +02:00
parent ff9b5b1861
commit 447a9dd266
234 changed files with 1990 additions and 1224 deletions

View File

@@ -3,7 +3,6 @@
namespace Kirby\Form;
use Exception;
use Kirby\Cms\App;
use Kirby\Cms\Model;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Toolkit\Component;
@@ -23,7 +22,6 @@ use Kirby\Toolkit\V;
*/
class Field extends Component
{
/**
* Registry for all component mixins
*
@@ -51,6 +49,10 @@ class Field extends Component
throw new InvalidArgumentException('The field type "' . $type . '" does not exist');
}
if (isset($attrs['model']) === false) {
throw new InvalidArgumentException('Field requires a model');
}
// use the type as fallback for the name
$attrs['name'] = $attrs['name'] ?? $type;
$attrs['type'] = $type;
@@ -71,6 +73,7 @@ class Field extends Component
}
/**
* @param mixed $default
* @return mixed
*/
public function data($default = false)
@@ -177,6 +180,39 @@ class Field extends Component
'value' => function ($value = null) {
return $value;
}
],
'computed' => [
'after' => function () {
if ($this->after !== null) {
return $this->model()->toString($this->after);
}
},
'before' => function () {
if ($this->before !== null) {
return $this->model()->toString($this->before);
}
},
'default' => function () {
if ($this->default === null) {
return;
}
if (is_string($this->default) === false) {
return $this->default;
}
return $this->model()->toString($this->default);
},
'label' => function () {
if ($this->label !== null) {
return $this->model()->toString($this->label);
}
},
'placeholder' => function () {
if ($this->placeholder !== null) {
return $this->model()->toString($this->placeholder);
}
}
]
];
}
@@ -217,7 +253,7 @@ class Field extends Component
}
/**
* @return Kirby\Cms\App
* @return \Kirby\Cms\App
*/
public function kirby()
{