Skip to content
Snippets Groups Projects
Commit b57d9fb0 authored by Justin Toupin's avatar Justin Toupin
Browse files

Configurable position and label for behaviors form.

parent 749e9f4a
No related tags found
No related merge requests found
show_paragraph_labels: 0
show_layout_labels: 0
\ No newline at end of file
show_layout_labels: 0
paragraph_behaviors_label: 'Behaviors'
paragraph_behaviors_position: -99
\ No newline at end of file
......@@ -10,6 +10,14 @@ layout_paragraphs.settings:
type: integer
label: 'Show Layout Labels'
description: 'This option allows to show the Paragraphs Layout Label of each Item added in LP widget Sections/Layouts'
paragraph_behaviors_label:
type: string
label: 'Paragraph behaviors label'
descripton: 'The paragraph behaviors form fieldset label'
paragraph_behaviors_position:
type: integer
label: 'Paragraph behaviors fieldset position'
description: 'Wheter to render the paragraph behaviors at the top or bottom of paragraph edit forms'
layout_paragraphs.modal_settings:
type: config_object
......@@ -27,7 +35,7 @@ layout_paragraphs.modal_settings:
type: boolean
label: 'Modal autoresize'
description: 'If checked modal forms will automatically resize.'
field.formatter.settings.layout_paragraphs:
type: mapping
label: 'Layout Paragraphs format settings'
......
......@@ -138,6 +138,7 @@ abstract class ComponentFormBase extends FormBase {
$display = EntityFormDisplay::collectRenderDisplay($this->paragraph, 'default');
$display->buildForm($this->paragraph, $form, $form_state);
$this->paragraphType = $this->paragraph->getParagraphType();
$lp_config = $this->config('layout_paragraphs.settings');
$form += [
'#title' => $this->formTitle(),
......@@ -148,7 +149,7 @@ abstract class ComponentFormBase extends FormBase {
[$this, 'afterBuild'],
],
'actions' => [
'#weight' => 20,
'#weight' => 100,
'#type' => 'actions',
'submit' => [
'#type' => 'submit',
......@@ -189,6 +190,9 @@ abstract class ComponentFormBase extends FormBase {
if (count($this->getEnabledBehaviorPlugins())) {
$form['behavior_plugins'] = [
'#weight' => $lp_config->get('paragraph_behaviors_position') ?? -99,
'#type' => 'details',
'#title' => $lp_config->get('paragraph_behaviors_label') ?? $this->t('Behaviors'),
'#process' => [
[$this, 'behaviorPluginsForm'],
],
......
......@@ -84,6 +84,22 @@ class LayoutParagraphsSettingsForm extends ConfigFormBase {
'#default_value' => $lp_config->get('show_layout_labels'),
];
$form['paragraph_behaviors_label'] = [
'#type' => 'textfield',
'#title' => $this->t('Paragraph Behaviors Fieldset Label'),
'#default_value' => $lp_config->get('paragraph_behaviors_label'),
];
$form['paragraph_behaviors_position'] = [
'#type' => 'radios',
'#title' => $this->t('Paragraph Behaviors Fieldset Position'),
'#options' => [
'-99' => $this->t('Top of paragraph edit form'),
'99' => $this->t('Bottom of paragraph edit form'),
],
'#default_value' => $lp_config->get('paragraph_behaviors_position'),
];
return parent::buildForm($form, $form_state);
}
......@@ -94,6 +110,8 @@ class LayoutParagraphsSettingsForm extends ConfigFormBase {
$lp_config = $this->configFactory()->getEditable('layout_paragraphs.settings');
$lp_config->set('show_paragraph_labels', $form_state->getValue('show_paragraph_labels'));
$lp_config->set('show_layout_labels', $form_state->getValue('show_layout_labels'));
$lp_config->set('paragraph_behaviors_label', $form_state->getValue('paragraph_behaviors_label'));
$lp_config->set('paragraph_behaviors_position', $form_state->getValue('paragraph_behaviors_position'));
$lp_config->save();
// Confirmation on form submission.
$this->messenger()->addMessage($this->t('The Layout Paragraphs settings have been saved.'));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment