Skip to content

Commit

Permalink
Add support for closeable form element container
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Tubach committed Aug 5, 2024
1 parent 53dfb1e commit 3511912
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Civi/RemoteTools/Form/FormSpec/FormElementContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,20 @@
*/
class FormElementContainer extends AbstractFormElementContainer implements FormElementInterface {

private bool $closeable = FALSE;

public function getType(): string {
return 'container';
}

public function isCloseable(): bool {
return $this->closeable;
}

public function setCloseable(bool $closeable): self {
$this->closeable = $closeable;

return $this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Civi\RemoteTools\JsonForms\FormSpec\ElementUiSchemaFactoryInterface;
use Civi\RemoteTools\JsonForms\FormSpec\Factory\AbstractConcreteElementUiSchemaFactory;
use Civi\RemoteTools\JsonForms\JsonFormsElement;
use Civi\RemoteTools\JsonForms\Layout\JsonFormsCloseableGroup;
use Civi\RemoteTools\JsonForms\Layout\JsonFormsGroup;
use Webmozart\Assert\Assert;

Expand All @@ -37,6 +38,10 @@ public function createSchema(
/** @var \Civi\RemoteTools\Form\FormSpec\FormElementContainer $element */
$elements = array_map([$factory, 'createSchema'], $element->getElements());

if ($element->isCloseable()) {
return new JsonFormsCloseableGroup($element->getTitle(), $elements);
}

return new JsonFormsGroup($element->getTitle(), $elements);
}

Expand Down

0 comments on commit 3511912

Please sign in to comment.