Skip to content

Commit

Permalink
Merge pull request #44 from systopia/HtmlMarkupArrayFactory-display-m…
Browse files Browse the repository at this point in the history
…arkup-only-if-no-label-set

HtmlMarkupArrayFactory: Display only markup only if no label is set
  • Loading branch information
dontub authored Dec 13, 2023
2 parents 2d93a05 + 94a3248 commit c5c2477
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Form/Markup/HtmlMarkupArrayFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@ public function createFormArray(DefinitionInterface $definition,
/** @var \Drupal\json_forms\JsonForms\Definition\Markup\MarkupDefinition $definition */

$element = [
'#type' => 'item',
'#title' => $definition->getLabel(),
'#markup' => $definition->getContent(),
];

if (NULL !== $definition->getRule()) {
$element['#states'] = $this->statesArrayFactory->createStatesArray($definition->getRule());
// Only use 'item' as type if necessary, otherwise just display the markup.
if (NULL !== $definition->getLabel() || NULL !== $definition->getRule()) {
$element['#type'] = 'item';
$element['#input'] = FALSE;
$element['#title'] = $definition->getLabel();
if (NULL !== $definition->getRule()) {
$element['#states'] = $this->statesArrayFactory->createStatesArray($definition->getRule());
}
}

return $element;
Expand Down

0 comments on commit c5c2477

Please sign in to comment.