Upgrade to 3.3.0
This commit is contained in:
@@ -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);
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user