diff --git a/config/install/layout_paragraphs.settings.yml b/config/install/layout_paragraphs.settings.yml index f0e9c4388b923242d405e9741b3f1e3f84f28c20..a104343701773c197ead6b2ab4a059e9a1c7712d 100644 --- a/config/install/layout_paragraphs.settings.yml +++ b/config/install/layout_paragraphs.settings.yml @@ -1,2 +1,4 @@ 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 diff --git a/config/schema/layout_paragraphs.schema.yml b/config/schema/layout_paragraphs.schema.yml index 8f08bb17813d4b0dc57a38510dcbde3f0139ab0c..2443cb5bbe3f9ada7af911816135dab82fba8048 100644 --- a/config/schema/layout_paragraphs.schema.yml +++ b/config/schema/layout_paragraphs.schema.yml @@ -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' diff --git a/src/Form/ComponentFormBase.php b/src/Form/ComponentFormBase.php index d2b708f021bda1ab8fc7cd26060c2ca74bc36e7c..d876b2a184cb3b1a42766b7a1628f7e1298dd75b 100644 --- a/src/Form/ComponentFormBase.php +++ b/src/Form/ComponentFormBase.php @@ -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'], ], diff --git a/src/Form/LayoutParagraphsSettingsForm.php b/src/Form/LayoutParagraphsSettingsForm.php index 211d2bd6988bbe5bc95a4df6277fc141b49a14d9..4529b09542d52f292458d4bdc0ceaa9339255630 100644 --- a/src/Form/LayoutParagraphsSettingsForm.php +++ b/src/Form/LayoutParagraphsSettingsForm.php @@ -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.'));