Skip to content

Commit 33ae51f

Browse files
Merge pull request #670 from creative-commoners/pulls/6.0/rename-ffv
DOC Rename FormField method
2 parents 1ac73e3 + 241fcba commit 33ae51f

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

en/02_Developer_Guides/03_Forms/00_Introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class MyFormPageController extends PageController
388388
echo $data['Email'];
389389

390390
// You can also fetch the value from the field.
391-
echo $form->Fields()->dataFieldByName('Email')->Value();
391+
echo $form->Fields()->dataFieldByName('Email')->getValue();
392392

393393
// Using the Form instance you can get / set status such as error messages.
394394
$form->sessionMessage('Successful!', 'good');

en/02_Developer_Guides/03_Forms/01_Validation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class FormFieldValidationExtension extends Extension
9090
{
9191
protected function updateValidate(ValidationResult $result): void
9292
{
93-
if (str_ends_with($this->owner->Value(), '@example.com')) {
93+
if (str_ends_with($this->owner->getValue(), '@example.com')) {
9494
$result->addFieldError(
9595
$this->getOwner()->Name(),
9696
'Please provide a valid email address which does not end with @example.com'
@@ -118,7 +118,7 @@ class CustomNumberField extends NumericField
118118
public function validate(): ValidationResult
119119
{
120120
$this->beforeExtending('updateValidate', function (ValidationResult $result) {
121-
if ((int) $this->Value() === 20) {
121+
if ((int) $this->getValue() === 20) {
122122
$result->addFieldError($this->Name(), 'This value cannot be 20');
123123
}
124124
});

en/02_Developer_Guides/09_Security/05_Secure_Coding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class MyForm extends Form
144144
}
145145
```
146146

147-
- `FormField->Value()`
147+
- `FormField->getValue()`
148148
- URLParams passed to a Controller-method
149149

150150
Example:

en/08_Changelogs/6.0.0.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ title: 6.0.0 (unreleased)
3737
- [`FormField` classes now use `FieldValidator` for validation](#formfield-validation)
3838
- [Most extension hook methods are now protected](#hooks-protected)
3939
- [Changes to some extension hook names](#hooks-renamed)
40+
- [`FormField::Value()` split into two methods](#formfield-value)
4041
- [Strict typing for `Factory` implementations](#factory-strict-typing)
4142
- [Elemental `TopPage` class names changed](#elemental-top-page)
4243
- [List interface changes](#list-interface-changes)
@@ -1044,6 +1045,12 @@ The `updateCurrentRecordID` extension hook method is now invoked from [`LeftAndM
10441045

10451046
If you have implemented any of those methods in an [`Extension`](api:SilverStripe\Core\Extension) subclass, you will need to rename them for them to continue working.
10461047

1048+
### `FormField::Value()` split into two methods {#formfield-value}
1049+
1050+
`SilverStripe\Forms\FormField::Value()` has been split into to [`FormField::getValue()`](api:SilverStripe\Forms\FormField::getValue()) which usually returns an unmodified version of the value, and [`FormField::getFormattedValue()`](api:SilverStripe\Forms\FormField::getFormattedValue()) which is intended to be modified with things like localisation formatting and will be displayed to users.
1051+
1052+
If you have overridden the `Value()` method in a subclass, you will need to update the method name to one of these, depending on the purpose of the custom functionality. If you use `$Value` in a template to get the value of a form field, you will need to update it to `$FormattedValue`.
1053+
10471054
### Strict typing for `Factory` implementations {#factory-strict-typing}
10481055

10491056
The [`Factory::create()`](api:SilverStripe\Core\Injector\Factory::create()) method now has strict typehinting. The first argument must be a string, and either `null` or an object must be returned.

0 commit comments

Comments
 (0)