Problem/Motivation
When you added $element['#title'] = '';
in ComponentSlotForm::buildForm() to hide the table header, you also remove the value from ComponentFormBase::preRenderPropOrSlot() which is now taking the slot ID instead of title:
$title = !empty($element['#title']) ? $element['#title'] : $prop_or_slot_id;
Proposed resolution
Can you restore the title?
Remaining tasks
Also, little simplification proposal for slots & props heading:
--- a/src/Element/ComponentPropsForm.php
+++ b/src/Element/ComponentPropsForm.php
@@ -74,18 +74,13 @@ class ComponentPropsForm extends ComponentFormBase {
return $element;
}
$configuration = $element['#default_value']['props'] ?? [];
- $is_first_prop = TRUE;
- $prop_heading = new FormattableMarkup("<p><strong>@title</strong></p>", ["@title" => t("Props")]);
+ $element[] = [
+ '#markup' => new FormattableMarkup("<p><strong>@title</strong></p>", ["@title" => t("Props")]),
+ ];
foreach ($props as $prop_id => $prop) {
if ($prop_id === 'variant') {
continue;
}
- if ($is_first_prop) {
- $element[] = [
- '#markup' => $prop_heading,
- ];
- $is_first_prop = FALSE;
- }
$prop_type = $prop['ui_patterns']['type_definition'];
$element[$prop_id] = [
'#type' => 'component_prop_form',
diff --git a/src/Element/ComponentSlotsForm.php b/src/Element/ComponentSlotsForm.php
index 605083b2..47714cea 100644
--- a/src/Element/ComponentSlotsForm.php
+++ b/src/Element/ComponentSlotsForm.php
@@ -72,15 +72,10 @@ class ComponentSlotsForm extends ComponentFormBase {
}
$contexts = $element['#source_contexts'] ?? [];
$configuration = $element['#default_value']['slots'] ?? [];
- $is_first_slot = TRUE;
- $slot_heading = new FormattableMarkup("<p><strong>@title</strong></p>", ["@title" => t("Slots")]);
+ $element[] = [
+ '#markup' => new FormattableMarkup("<p><strong>@title</strong></p>", ["@title" => t("Slots")]),
+ ];
foreach ($component->metadata->slots as $slot_id => $slot) {
- if ($is_first_slot) {
- $element[] = [
- '#markup' => $slot_heading,
- ];
- $is_first_slot = FALSE;
- }
$element[$slot_id] = [
'#title' => $slot['title'] ?? '',