diff --git a/src/Form/InsertComponentForm.php b/src/Form/InsertComponentForm.php index ce6f981ad116fde3f4d3c04b48cb2a4b96b0b19d..5a2372db1b2ba8e802fa65d673fa97a809b39cf2 100644 --- a/src/Form/InsertComponentForm.php +++ b/src/Form/InsertComponentForm.php @@ -26,6 +26,13 @@ class InsertComponentForm extends ComponentFormBase { */ protected $domSelector; + /** + * Default values for new paragraph. + * + * @var array + */ + protected $paragraphDefaults = []; + /** * The jQuery insertion method to use for adding the new component. * @@ -84,6 +91,8 @@ class InsertComponentForm extends ComponentFormBase { * The uuid of the sibling component. * @param string $placement * Where to place the new component - either "before" or "after". + * @param array $paragraph_defaults + * Default values for the new paragraph. */ public function buildForm( array $form, @@ -93,9 +102,13 @@ class InsertComponentForm extends ComponentFormBase { string $parent_uuid = NULL, string $region = NULL, string $sibling_uuid = NULL, - string $placement = NULL + string $placement = NULL, + array $paragraph_defaults = [] ) { + if (!empty($paragraph_defaults)) { + $this->paragraphDefaults = $paragraph_defaults; + } $this->setLayoutParagraphsLayout($layout_paragraphs_layout); $langcode = $this->layoutParagraphsLayout->getEntity()->language()->getId(); $this->paragraph = $this->newParagraph($paragraph_type, $langcode); @@ -231,7 +244,7 @@ class InsertComponentForm extends ComponentFormBase { $bundle_key => $paragraph_type->id(), $langcode_key => $langcode, '_layoutParagraphsLayout' => $this->getLayoutParagraphsLayout(), - ]); + ] + $this->paragraphDefaults); return $paragraph; }