From 74dd68c88711f9cafe4301ade88eca10d178e044 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 15 Nov 2024 14:02:54 +1300 Subject: [PATCH] FIX Avoid infinite recursive loop with attributes in schemadata --- src/Form/BlockLinkField.php | 16 ---------------- .../ElementalBannerBlock/Form/BlockLinkField.ss | 2 +- tests/Form/BlockLinkFieldTest.php | 7 ------- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/Form/BlockLinkField.php b/src/Form/BlockLinkField.php index 580a300..db77f63 100644 --- a/src/Form/BlockLinkField.php +++ b/src/Form/BlockLinkField.php @@ -134,22 +134,6 @@ public function getShowLinkText() return $this->showLinkText; } - /** - * When not used in a React form factory context, this adds the schema and state data to SilverStripe - * template rendered attributes lists - * - * @return array - */ - public function getAttributes() - { - $attributes = parent::getAttributes(); - - $attributes['data-schema'] = json_encode($this->getSchemaData()); - $attributes['data-state'] = json_encode($this->getSchemaState()); - - return $attributes; - } - /** * Add some extra props for the React component to work with * diff --git a/templates/SilverStripe/ElementalBannerBlock/Form/BlockLinkField.ss b/templates/SilverStripe/ElementalBannerBlock/Form/BlockLinkField.ss index 80e4223..9179e1a 100644 --- a/templates/SilverStripe/ElementalBannerBlock/Form/BlockLinkField.ss +++ b/templates/SilverStripe/ElementalBannerBlock/Form/BlockLinkField.ss @@ -1,3 +1,3 @@ -
+
<%-- Rendered by the BlockLinkField React component --%>
diff --git a/tests/Form/BlockLinkFieldTest.php b/tests/Form/BlockLinkFieldTest.php index de60da8..539fa09 100644 --- a/tests/Form/BlockLinkFieldTest.php +++ b/tests/Form/BlockLinkFieldTest.php @@ -64,13 +64,6 @@ public function testGetSetShowLinkText() $this->assertFalse($this->field->getShowLinkText(), 'Link text field can be disabled'); } - public function testGetAttributes() - { - $attributes = $this->field->getAttributes(); - $this->assertArrayHasKey('data-schema', $attributes); - $this->assertArrayHasKey('data-state', $attributes); - } - public function testGetSchemaDataDefault() { $schemaDataDefaults = $this->field->getSchemaDataDefaults();