From 27c7539f6f9c4108dc70108446019bfee5ffacc4 Mon Sep 17 00:00:00 2001 From: Tony Air Date: Mon, 28 Feb 2022 14:23:43 +0200 Subject: [PATCH] IMPR: Add some options to Accordion element --- src/Elements/AccordionElement.php | 18 ++++++++++++++++++ .../Elements/AccordionElement_AccordionArea.ss | 8 +++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/Elements/AccordionElement.php b/src/Elements/AccordionElement.php index 767e30a..8af5739 100755 --- a/src/Elements/AccordionElement.php +++ b/src/Elements/AccordionElement.php @@ -9,6 +9,7 @@ namespace A2nt\ElementalBasics\Elements; use DNADesign\ElementalList\Model\ElementList; +use SilverStripe\Forms\CheckboxField; class AccordionElement extends ElementList { @@ -21,6 +22,11 @@ class AccordionElement extends ElementList private static $table_name = 'AccordionElement'; + private static $db = [ + 'OpenFirst' => 'Boolean(0)', + 'KeepOpenned' => 'Boolean(0)', + ]; + public function getType() { return self::$singular_name; @@ -30,4 +36,16 @@ class AccordionElement extends ElementList { return $this->Elements()->renderWith(static::class.'_AccordionArea'); } + + public function getCMSFields() + { + $fields = parent::getCMSFields(); + + $fields->addFieldsToTab('Root.Main', [ + CheckboxField::create('OpenFirst', 'Open first accordion element on page load'), + CheckboxField::create('KeepOpenned', 'Keep elements oppened'), + ]); + + return $fields; + } } diff --git a/templates/A2nt/ElementalBasics/Elements/AccordionElement_AccordionArea.ss b/templates/A2nt/ElementalBasics/Elements/AccordionElement_AccordionArea.ss index 392fd32..7f7630b 100755 --- a/templates/A2nt/ElementalBasics/Elements/AccordionElement_AccordionArea.ss +++ b/templates/A2nt/ElementalBasics/Elements/AccordionElement_AccordionArea.ss @@ -6,7 +6,7 @@ @@ -14,9 +14,11 @@
+ data-bs-parent="#ElementAccordion{$Parent.ID}" + <% end_if %> >
$Me