Skip to content

Commit

Permalink
Merge branch '3' into 4
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 11, 2024
2 parents 5f7fb88 + 63cfb0d commit 656598a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ReadonlyTagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public function Field($properties = array())
{
$options = array();

foreach ($this->getOptions()->filter('Selected', true) as $option) {
// only get the selected options
foreach ($this->getOptions(true) as $option) {
$options[] = $option->Title;
}

Expand Down
16 changes: 16 additions & 0 deletions tests/TagFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,22 @@ public function testReadonlyTransformation()
$field->setTitleField('Name');
$readOnlyField = $field->performReadonlyTransformation();
$this->assertEquals('Name', $readOnlyField->getTitleField());

// Also check Field options
$field = new TagField('Tags', '', TagFieldTestBlogTag::get());
$field->setTitleField('Title');
$field->setValue(['Tag1']);

// When not read only (and not lazy-loading) all source options are returned
$htmlText = $field->Field();
$this->assertStringContainsString('Tag1', $htmlText);
$this->assertStringContainsString('222', $htmlText);

// When read only mode, only selected options are returned
$readOnlyField = $field->performReadonlyTransformation();
$htmlText = $readOnlyField->Field();
$this->assertStringContainsString('Tag1', $htmlText);
$this->assertStringNotContainsString('222', $htmlText);
}

public function testItDisplaysWithSelectedValuesFromDataList()
Expand Down

0 comments on commit 656598a

Please sign in to comment.