-
-
Save ChVuagniaux/003bb50cc1c8e08a9396f0f2bfdd15ee to your computer and use it in GitHub Desktop.
Add nested translated repeaters to RainLab.Pages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function boot() | |
{ | |
Event::listen('backend.form.extendFieldsBefore', function (\Backend\Widgets\Form $form) { | |
$isStaticPage = $form->getController() instanceof \RainLab\Pages\Controllers\Index | |
&& $form->model instanceof \RainLab\Pages\Classes\Page; | |
if ($isStaticPage && !$form->isNested) { | |
$fields = Yaml::parse(<<<YAML | |
title: | |
label: Title | |
type: text | |
span: full | |
blocks: | |
label: Blocks | |
type: repeater | |
prompt: Add block | |
form: | |
fields: | |
title: | |
label: Title | |
type: text | |
span: full | |
content: | |
label: Content | |
type: richeditor | |
span: full | |
YAML | |
); | |
$form->secondaryTabs['fields'] = [ | |
'viewBag[sections]' => [ | |
'tab' => 'Sections', | |
'type' => 'repeater', | |
'form' => ['fields' => $fields], | |
'prompt' => 'Ajouter une section', | |
'cssClass' => 'secondary-tab ', | |
], | |
] + $form->secondaryTabs['fields']; | |
$form->model->translatable[] = 'viewBag[sections]'; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment