diff --git a/src/Element/Pattern.php b/src/Element/Pattern.php index e04ea99a..2bf170a5 100644 --- a/src/Element/Pattern.php +++ b/src/Element/Pattern.php @@ -156,13 +156,14 @@ public static function processMultipleSources(array $element) { if (count($field) > 1) { /** @var \Drupal\ui_patterns\Element\PatternContext $context */ $context = $element['#context']; - $context->setProperty('pattern', $element['#id']); - $context->setProperty('field', $name); + $field_context = new PatternContext($context->getType(), $context->getProperties()); + $field_context->setProperty('pattern', $element['#id']); + $field_context->setProperty('field', $name); // Render multiple sources with "patterns_destination" template. $element['#fields'][$name] = [ '#sources' => $field, - '#context' => $context, + '#context' => $field_context, '#theme' => 'patterns_destination', ]; } diff --git a/src/Element/PatternContext.php b/src/Element/PatternContext.php index 48f0ab34..911abb4a 100644 --- a/src/Element/PatternContext.php +++ b/src/Element/PatternContext.php @@ -49,6 +49,16 @@ public function getProperty($name) { return isset($this->properties[$name]) ? $this->properties[$name] : NULL; } + /** + * Get pattern context properties. + * + * @return mixed + * All context properties. + */ + public function getProperties() { + return $this->properties; + } + /** * Set pattern context property. *