Skip to content

Commit

Permalink
FIX Avoid infinite recursive loop with attributes in schemadata (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Nov 24, 2024
1 parent 34d8a5b commit d861cad
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 d861cad

Please sign in to comment.