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 15, 2024
1 parent 656598a commit f2c79d2
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 29 deletions.
13 changes: 0 additions & 13 deletions src/StringTagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,6 @@ protected function formatOptions($fieldValue)
return $formattedValue;
}

/**
* When not used in a React form factory context, this adds the schema data to SilverStripe template
* rendered attributes lists
*
* @return array
*/
public function getAttributes()
{
$attributes = parent::getAttributes();
$attributes['data-schema'] = json_encode($this->getSchemaData());
return $attributes;
}

/**
* @return string
*/
Expand Down
1 change: 0 additions & 1 deletion src/TagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ public function getAttributes()
[
'name' => $name,
'style' => 'width: 100%',
'data-schema' => json_encode($this->getSchemaData()),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion templates/SilverStripe/TagField/TagField.ss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<div $AttributesHTML></div>
<div $AttributesHTML data-schema="$SchemaData.JSON"></div>
7 changes: 0 additions & 7 deletions tests/StringTagFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@ public function testGetSchemaDataDefaults()
$this->assertStringContainsString('suggest', $schema['optionUrl']);
}

public function testSchemaIsAddedToAttributes()
{
$field = new StringTagField('TestField');
$attributes = $field->getAttributes();
$this->assertNotEmpty($attributes['data-schema']);
}

public function testPerformReadonlyTransformation()
{
$field = new StringTagField('Tags');
Expand Down
7 changes: 0 additions & 7 deletions tests/TagFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,6 @@ public function testGetSchemaDataDefaults()
$this->assertStringContainsString('suggest', $schema['optionUrl']);
}

public function testSchemaIsAddedToAttributes()
{
$field = new TagField('TestField');
$attributes = $field->getAttributes();
$this->assertNotEmpty($attributes['data-schema']);
}

/**
* @param array $options
* @param string $title
Expand Down

0 comments on commit f2c79d2

Please sign in to comment.