Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for collapsible form element container #51

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 $collapsible = FALSE;

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

public function isCollapsible(): bool {
return $this->collapsible;
}

public function setCollapsible(bool $collapsible): self {
$this->collapsible = $collapsible;

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->isCollapsible()) {
return new JsonFormsCloseableGroup($element->getTitle(), $elements);
}

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

Expand Down
Loading