From aa1876286d23dad8ef1a9d2d7039b5b85f837a7c Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Thu, 23 Jan 2025 17:02:11 +1300 Subject: [PATCH] DOC Rename FormField method --- en/02_Developer_Guides/03_Forms/00_Introduction.md | 2 +- en/02_Developer_Guides/03_Forms/01_Validation.md | 4 ++-- en/02_Developer_Guides/09_Security/05_Secure_Coding.md | 2 +- en/08_Changelogs/6.0.0.md | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/en/02_Developer_Guides/03_Forms/00_Introduction.md b/en/02_Developer_Guides/03_Forms/00_Introduction.md index 5270b8c0..f887801c 100644 --- a/en/02_Developer_Guides/03_Forms/00_Introduction.md +++ b/en/02_Developer_Guides/03_Forms/00_Introduction.md @@ -388,7 +388,7 @@ class MyFormPageController extends PageController echo $data['Email']; // You can also fetch the value from the field. - echo $form->Fields()->dataFieldByName('Email')->Value(); + echo $form->Fields()->dataFieldByName('Email')->getValue(); // Using the Form instance you can get / set status such as error messages. $form->sessionMessage('Successful!', 'good'); diff --git a/en/02_Developer_Guides/03_Forms/01_Validation.md b/en/02_Developer_Guides/03_Forms/01_Validation.md index a348a8e3..04d3c65d 100644 --- a/en/02_Developer_Guides/03_Forms/01_Validation.md +++ b/en/02_Developer_Guides/03_Forms/01_Validation.md @@ -90,7 +90,7 @@ class FormFieldValidationExtension extends Extension { protected function updateValidate(ValidationResult $result): void { - if (str_ends_with($this->owner->Value(), '@example.com')) { + if (str_ends_with($this->owner->getValue(), '@example.com')) { $result->addFieldError( $this->getOwner()->Name(), 'Please provide a valid email address which does not end with @example.com' @@ -118,7 +118,7 @@ class CustomNumberField extends NumericField public function validate(): ValidationResult { $this->beforeExtending('updateValidate', function (ValidationResult $result) { - if ((int) $this->Value() === 20) { + if ((int) $this->getValue() === 20) { $result->addFieldError($this->Name(), 'This value cannot be 20'); } }); diff --git a/en/02_Developer_Guides/09_Security/05_Secure_Coding.md b/en/02_Developer_Guides/09_Security/05_Secure_Coding.md index 3f03c57f..fbd4cb96 100644 --- a/en/02_Developer_Guides/09_Security/05_Secure_Coding.md +++ b/en/02_Developer_Guides/09_Security/05_Secure_Coding.md @@ -144,7 +144,7 @@ class MyForm extends Form } ``` -- `FormField->Value()` +- `FormField->getValue()` - URLParams passed to a Controller-method Example: diff --git a/en/08_Changelogs/6.0.0.md b/en/08_Changelogs/6.0.0.md index 75b063a1..43507f99 100644 --- a/en/08_Changelogs/6.0.0.md +++ b/en/08_Changelogs/6.0.0.md @@ -1088,6 +1088,7 @@ As part of these changes [`ArrayList::find()`](api:SilverStripe\Model\List\Array - `SilverStripe\ORM\DataExtension`, `SilverStripe\CMS\Model\SiteTreeExtension`, and `SilverStripe\Admin\LeftAndMainExtension` have been removed. If you subclass any of these classes, you must now subclass [`Extension`](api:SilverStripe\Core\Extension) directly instead. - [`DBCurrency`](api:SilverStripe\ORM\FieldType\DBCurrency) will no longer parse numeric values contained in a string when calling `setValue()`. For instance "this is 50.29 dollars" will no longer be converted to "$50.29", instead its value will remain as "this is 50.29 dollars" and it will throw a validation exception if attempted to be written to the database. - The `SilverStripe\Model\List\ArrayList.default_case_sensitive` configuration property has been removed. This means the default case sensitivity of `ArrayList` is now the same as any other list which uses search filters. If you were using that configuration property, or you were relying on `ArrayList` being case sensitive by default, you should double check that your list filters are working the way you expect. See [search filters](/developer_guides/model/searchfilters/#modifiers) for details about case sensitivity in search filters. +- `SilverStripe\Forms\FormField::Value()` has been split into to [`FormField::getValue()`](api:SilverStripe\Forms\FormField::getValue()) which usually returns an unmodified version of the field, and [`FormField::getFormattedValue()`](api:SilverStripe\Forms\FormField::getFormattedValue()) which is intended to be modified with things like localisation formatting. If you have overridden the `Value()` method in a subclass, you will need to update the method name, usuall to `getFormattedValue()`. If you have use `$Value` in a template to get the value of a form field, you will also need to update it to `$FormattedValue`. ## Other changes