julienmonnerie/kirby/config/sections/fields.php
2025-07-11 14:41:34 +02:00

34 lines
587 B
PHP

<?php
use Kirby\Form\Form;
return [
'props' => [
'fields' => function (array $fields = []) {
return $fields;
}
],
'computed' => [
'form' => function () {
return new Form(
fields: $this->fields,
model: $this->model,
language: 'current'
);
},
'fields' => function () {
return $this->form->fields()->toProps();
}
],
'methods' => [
'errors' => function () {
$this->form->fill($this->model->content('current')->toArray());
return $this->form->errors();
}
],
'toArray' => function () {
return [
'fields' => $this->fields,
];
}
];