Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andybroomfield/9a9ae83df8f3f012b6d59cc4becfffd9 to your computer and use it in GitHub Desktop.
Save andybroomfield/9a9ae83df8f3f012b6d59cc4becfffd9 to your computer and use it in GitHub Desktop.
Patch for Drupal Paragrams with field group horizontal tabs
diff --git a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
index ce8d108..2d9bda9 100644
--- a/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
+++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
@@ -643,7 +643,7 @@ class InlineParagraphsWidget extends WidgetBase {
];
field_group_attach_groups($element['subform'], $context);
- $element['subform']['#pre_render'][] = 'field_group_form_pre_render';
+ $element['subform']['#process'][] = 'field_group_form_process';
}
if ($item_mode == 'edit') {
@@ -1320,8 +1320,9 @@ class InlineParagraphsWidget extends WidgetBase {
$item['target_revision_id'] = $paragraphs_entity->getRevisionId();
}
// If our mode is remove don't save or reference this entity.
+ // The check to see if mode is present is due to field group tabs.
// @todo: Maybe we should actually delete it here?
- elseif($widget_state['paragraphs'][$item['_original_delta']]['mode'] == 'remove' || $widget_state['paragraphs'][$item['_original_delta']]['mode'] == 'removed') {
+ elseif(isset($widget_state['paragraphs'][$item['_original_delta']]['mode']) && ($widget_state['paragraphs'][$item['_original_delta']]['mode'] == 'remove' || $widget_state['paragraphs'][$item['_original_delta']]['mode'] == 'removed')) {
$item['target_id'] = NULL;
$item['target_revision_id'] = NULL;
}
diff --git a/src/Plugin/Field/FieldWidget/ParagraphsWidget.php b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php
index edb24b9..a508a2e 100644
--- a/src/Plugin/Field/FieldWidget/ParagraphsWidget.php
+++ b/src/Plugin/Field/FieldWidget/ParagraphsWidget.php
@@ -758,7 +758,7 @@ class ParagraphsWidget extends WidgetBase {
];
field_group_attach_groups($element['subform'], $context);
- $element['subform']['#pre_render'][] = 'field_group_form_pre_render';
+ $element['subform']['#process'][] = 'field_group_form_process';
}
if ($item_mode == 'edit') {
@andybroomfield
Copy link
Author

See Drupal issue https://www.drupal.org/project/paragraphs/issues/2907094
Here so I can test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment