Skip to content

Commit

Permalink
Allow to use field_group label in patterns.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edouard Cunibil committed Nov 23, 2021
1 parent 6756e77 commit c09132b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getSourceFields() {
$sources[] = $this->getSourceField($group_name, $group->label);
}
}
$sources[] = $this->getSourceField('_label', 'Group label');

return $sources;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ protected function preRenderGroup(array &$element, $group_name, array $rendering
// Move content into their fields.
foreach ($group->format_settings['pattern_mapping'] as $field) {
if ($field['plugin'] == 'fieldgroup') {
$this->preRenderGroup($element[$field['source']], $field['source'], $rendering_object);
if ($field['source'] === '_label') {
$element[$field['source']] = ['#markup' => $group->label];
}
else {
$this->preRenderGroup($element[$field['source']], $field['source'], $rendering_object);
}
}
$element['#fields'][$field['destination']][$field['source']] = $element[$field['source']];
}
Expand Down

0 comments on commit c09132b

Please sign in to comment.