Skip to content

Commit

Permalink
TableRowArrayFactory: No desription for controls
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Tubach committed Apr 19, 2024
1 parent 4137e97 commit 3025055
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions src/Form/Layout/TableRowArrayFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ protected function createElementFormArray(
): array {

if ($element instanceof MarkupDefinition) {
$label = $element->getLabel();
$label = $element->getMarkupSchema()->label ?? NULL;
try {
// HtmlMarkupArrayFactory handles elements without label differently.
$element->getMarkupSchema()->label = NULL;
// If '#title_display' is set to 'hidden' the label should not be
// visible, but the HTML tags may still use some space.
$element->getMarkupSchema()->label = '';

return parent::createElementFormArray($element, $formState, $formArrayFactory);
}
Expand All @@ -60,16 +61,30 @@ protected function createElementFormArray(
}
}

$form = ['#title_display' => 'invisible']
+ parent::createElementFormArray($element, $formState, $formArrayFactory);
if ($element instanceof ControlDefinition) {
$description = $element->getControlSchema()->description ?? NULL;
try {
// The module "Form Tips" brings back label and description, even if
// '#description_display' is set to 'invisible'. Thus, we explicitly set
// an empty string here.
$element->getControlSchema()->description = '';
$form = ['#title_display' => 'invisible'];
if ('hidden' === $element->getOptionsValue('type')) {
// Use no space for table cell.
$form['#wrapper_attributes']['style'][] = 'padding: 0;';
}

if ($element instanceof ControlDefinition && 'hidden' === $element->getOptionsValue('type')) {
// Use no space for table cell.
// @phpstan-ignore-next-line
$form['#wrapper_attributes']['style'][] = 'padding: 0;';
return $form + parent::createElementFormArray($element, $formState, $formArrayFactory);
}
finally {
$element->getControlSchema()->description = $description;
}
}

return $form;
return [
'#title_display' => 'invisible',
'#description_display' => 'invisible',
] + parent::createElementFormArray($element, $formState, $formArrayFactory);
}

}

0 comments on commit 3025055

Please sign in to comment.