Hi.

Can you accept a patch to allow hook before paragraphs widget form prebuild?
It could be useful to allow another modules to hook before the widget is created.

Use case: paragraphs defaults module needs add paragraph but now it's not working with nested paragraphs, if it could add values before widget prebuiild it would works.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mistermoper created an issue. See original summary.

omarlopesino’s picture

Status: Active » Needs review
FileSize
1.35 KB

Attaching patch. It adds prebuild function in paragraphs_field_multiple_value_form , and a drupal alter.

Please review, thanks!

miro_dietiker’s picture

+++ b/paragraphs.field_widget.inc
@@ -53,6 +53,7 @@ function paragraphs_field_widget_form(&$form, &$form_state, $field, $instance, $
+  paragraphs_field_widget_form_pre_build($field, $instance, $langcode, $items, $form, $form_state, $delta, $original_element);

@@ -321,6 +322,25 @@ function paragraphs_field_multiple_value_form($field, $instance, $langcode, $ite
+function paragraphs_field_widget_form_pre_build($field, $instance, $langcode, $items, &$form, &$form_state, $delta, $original_element) {
...
+  drupal_alter('paragraphs_field_widget_form_pre_build', $context, $form, $form_state);

Double-wrap it through a stub method, while still needing to pass all those things in looks like double dip.