Page-specific Settings
You can add extra fields that will only be displayed when editing specific pages.
Limitations
Fields will only be visible after the page is saved - the slug must exist when the page is loaded for the fields to be loaded.
Setup
Add a function like this to your Crud config:
public function addHomeFields() {
$form = $this->getEditForm();
$form->addSections([
(new JsonDataSection('data'))
->setLabel('My Extra Data')
->addFields([
(new WysiwygField('my_extra_text_field')),
]),
]);
return $form;
}
- Method Name The method name must begin with
addand end withfieldswith the slug of the page, in Studly Case, in between. - Section Name In the example above the
'data'passed togetSectionByNamecorresponds to the name of the JSON column that the data will be stored on.datashould exist on yourpagestable by default but this means you can add extra columns if need be.