Skip to content

Commit c09132b

Browse files
author
Edouard Cunibil
committed
Allow to use field_group label in patterns.
1 parent 6756e77 commit c09132b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

modules/ui_patterns_field_group/src/Plugin/UiPatterns/Source/FieldgroupSource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function getSourceFields() {
3939
$sources[] = $this->getSourceField($group_name, $group->label);
4040
}
4141
}
42+
$sources[] = $this->getSourceField('_label', 'Group label');
4243

4344
return $sources;
4445
}

modules/ui_patterns_field_group/src/Plugin/field_group/FieldGroupFormatter/PatternFormatter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ protected function preRenderGroup(array &$element, $group_name, array $rendering
131131
// Move content into their fields.
132132
foreach ($group->format_settings['pattern_mapping'] as $field) {
133133
if ($field['plugin'] == 'fieldgroup') {
134-
$this->preRenderGroup($element[$field['source']], $field['source'], $rendering_object);
134+
if ($field['source'] === '_label') {
135+
$element[$field['source']] = ['#markup' => $group->label];
136+
}
137+
else {
138+
$this->preRenderGroup($element[$field['source']], $field['source'], $rendering_object);
139+
}
135140
}
136141
$element['#fields'][$field['destination']][$field['source']] = $element[$field['source']];
137142
}

0 commit comments

Comments
 (0)