julienmonnerie/kirby/config/sections/fields.php

35 lines
587 B
PHP
Raw Normal View History

2022-06-17 17:51:59 +02:00
<?php
use Kirby\Form\Form;
return [
2022-08-31 15:02:43 +02:00
'props' => [
'fields' => function (array $fields = []) {
return $fields;
}
],
'computed' => [
'form' => function () {
2025-07-11 14:41:34 +02:00
return new Form(
fields: $this->fields,
model: $this->model,
language: 'current'
);
2022-08-31 15:02:43 +02:00
},
'fields' => function () {
2025-07-11 14:41:34 +02:00
return $this->form->fields()->toProps();
2022-08-31 15:02:43 +02:00
}
],
'methods' => [
'errors' => function () {
2025-07-11 14:41:34 +02:00
$this->form->fill($this->model->content('current')->toArray());
2022-08-31 15:02:43 +02:00
return $this->form->errors();
}
],
'toArray' => function () {
return [
'fields' => $this->fields,
];
}
2022-06-17 17:51:59 +02:00
];