Initial commit
This commit is contained in:
commit
73c6b816c0
716 changed files with 170045 additions and 0 deletions
56
kirby/config/sections/fields.php
Normal file
56
kirby/config/sections/fields.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Form\Form;
|
||||
|
||||
return [
|
||||
'props' => [
|
||||
'fields' => function (array $fields = []) {
|
||||
return $fields;
|
||||
}
|
||||
],
|
||||
'computed' => [
|
||||
'form' => function () {
|
||||
$fields = $this->fields;
|
||||
$disabled = $this->model->permissions()->update() === false;
|
||||
$content = $this->model->content()->toArray();
|
||||
|
||||
if ($disabled === true) {
|
||||
foreach ($fields as $key => $props) {
|
||||
$fields[$key]['disabled'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return new Form([
|
||||
'fields' => $fields,
|
||||
'values' => $content,
|
||||
'model' => $this->model,
|
||||
'strict' => true
|
||||
]);
|
||||
},
|
||||
'fields' => function () {
|
||||
$fields = $this->form->fields()->toArray();
|
||||
|
||||
if (is_a($this->model, 'Kirby\Cms\Page') === true || is_a($this->model, 'Kirby\Cms\Site') === true) {
|
||||
// the title should never be updated directly via
|
||||
// fields section to avoid conflicts with the rename dialog
|
||||
unset($fields['title']);
|
||||
}
|
||||
|
||||
foreach ($fields as $index => $props) {
|
||||
unset($fields[$index]['value']);
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
],
|
||||
'methods' => [
|
||||
'errors' => function () {
|
||||
return $this->form->errors();
|
||||
}
|
||||
],
|
||||
'toArray' => function () {
|
||||
return [
|
||||
'fields' => $this->fields,
|
||||
];
|
||||
}
|
||||
];
|
Loading…
Add table
Add a link
Reference in a new issue