Skip to content

Commit

Permalink
FIX Avoid infinite recursive loop with attributes in schemadata
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Nov 19, 2024
1 parent c0f089c commit 74dd68c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
16 changes: 0 additions & 16 deletions src/Form/BlockLinkField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div $getAttributesHTML('name', 'type') data-useEntwine>
<div $getAttributesHTML('name', 'type') $SchemaAttributesHtml data-useEntwine>
<%-- Rendered by the BlockLinkField React component --%>
</div>
7 changes: 0 additions & 7 deletions tests/Form/BlockLinkFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 74dd68c

Please sign in to comment.