Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Rename FormField Value to getFormattedValue #317

Draft
wants to merge 1 commit into
base: 4.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/StringTagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getSchemaDataDefaults()
'lazyLoad' => $this->getShouldLazyLoad(),
'creatable' => $this->getCanCreate(),
'multi' => $this->getIsMultiple(),
'value' => $this->formatOptions($this->Value()),
'value' => $this->formatOptions($this->getFormattedValue()),
'disabled' => $this->isDisabled() || $this->isReadonly(),
]
);
Expand Down Expand Up @@ -384,7 +384,7 @@ public function setCanCreate($canCreate)
public function performReadonlyTransformation()
{
$field = parent::performReadonlyTransformation();
$field->setValue(implode(', ', $this->Value()));
$field->setValue(implode(', ', $this->getFormattedValue()));
return $field;
}
}
6 changes: 3 additions & 3 deletions tests/StringTagFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,18 @@ public function testPerformReadonlyTransformation()
// Ensure a single value can be rendered
$field->setValue(['Test2']);
$field_readonly = $field->performReadonlyTransformation();
$this->assertEquals('Test2', $field_readonly->Value());
$this->assertEquals('Test2', $field_readonly->getFormattedValue());

// Ensure multiple valid values are rendered
$field->setValue(['Test1', 'Test2']);
$field_readonly = $field->performReadonlyTransformation();
$this->assertEquals('Test1, Test2', $field_readonly->Value());
$this->assertEquals('Test1, Test2', $field_readonly->getFormattedValue());

// Ensure an value not in the source array is still rendered
// (because e.g. in history view it must have been a valid value when it was set)
$field->setValue(['Test', 'Test1']);
$field_readonly = $field->performReadonlyTransformation();
$this->assertEquals('Test, Test1', $field_readonly->Value());
$this->assertEquals('Test, Test1', $field_readonly->getFormattedValue());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TagFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public function testItDisplaysValuesFromRelations()

$ids = TagFieldTestBlogTag::get()->column('ID');

$this->assertEquals($field->Value(), $ids);
$this->assertEquals($field->getValue(), $ids);
}

public function testItIgnoresNewTagsIfCannotCreate()
Expand Down
Loading