Skip to content

Commit

Permalink
FIX Avoid infinite recursive loop with attributes in schemadata (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Nov 24, 2024
1 parent 88ae166 commit 7f50ea1
Show file tree
Hide file tree
Showing 5 changed files with 3 additions 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 $SchemaAttributesHtml></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
9 changes: 2 additions & 7 deletions tests/TagFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ public function testReadonlyTransformation()
$field = new TagField('Tags', '', TagFieldTestBlogTag::get());
$field->setTitleField('Title');
$field->setValue(['Tag1']);
$form = new Form();
$field->setForm($form);

// When not read only (and not lazy-loading) all source options are returned
$htmlText = $field->Field();
Expand Down Expand Up @@ -482,13 +484,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 7f50ea1

Please sign in to comment.