Upgrade to 3.3.0

This commit is contained in:
Bastian Allgeier
2019-11-05 09:35:58 +01:00
parent 447a9dd266
commit a431716732
186 changed files with 3068 additions and 1458 deletions

View File

@@ -203,6 +203,13 @@ class Field extends Component
return $this->model()->toString($this->default);
},
'help' => function () {
if ($this->help) {
$help = $this->model()->toString($this->help);
$help = $this->kirby()->kirbytext($help);
return $help;
}
},
'label' => function () {
if ($this->label !== null) {
return $this->model()->toString($this->label);

View File

@@ -61,14 +61,7 @@ class Form
try {
$field = new Field($props['type'], $props);
} catch (Throwable $e) {
$props = array_merge($props, [
'name' => $props['name'],
'label' => 'Error in "' . $props['name'] . '" field',
'theme' => 'negative',
'text' => $e->getMessage(),
]);
$field = new Field('info', $props);
$field = static::exceptionField($e, $props);
}
if ($field->save() !== false) {
@@ -127,6 +120,17 @@ class Form
return $this->errors;
}
public static function exceptionField(Throwable $exception, array $props = [])
{
$props = array_merge($props, [
'label' => 'Error in "' . $props['name'] . '" field',
'theme' => 'negative',
'text' => strip_tags($exception->getMessage()),
]);
return new Field('info', $props);
}
public function fields()
{
return $this->fields;