From dd062f3fee1f38d0e09e4a94240e535df97aa663 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 19 Nov 2024 13:55:27 +1300 Subject: [PATCH] API Rename method --- code/BasicFieldsTestPage.php | 10 +++++----- code/elemental/ElementContentExtension.php | 2 +- code/elemental/NumericFieldExtension.php | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/code/BasicFieldsTestPage.php b/code/BasicFieldsTestPage.php index b54e847..57af0e3 100644 --- a/code/BasicFieldsTestPage.php +++ b/code/BasicFieldsTestPage.php @@ -50,11 +50,11 @@ class BasicFieldsTestPage extends TestPage 'Money' => 'Money', 'MyCompositeField1' => 'Varchar', 'MyCompositeField2' => 'Varchar', - 'MyCompositeField3' => 'Varchar', + 'MyCompositeField3' => 'Int', 'MyCompositeFieldCheckbox' => 'Boolean', 'MyFieldGroup1' => 'Varchar', 'MyFieldGroup2' => 'Varchar', - 'MyFieldGroup3' => 'Varchar', + 'MyFieldGroup3' => 'Int', 'MyFieldGroupCheckbox' => 'Boolean', 'MyLabelledFieldGroup1' => 'Varchar', 'MyLabelledFieldGroup2' => 'Varchar', @@ -70,7 +70,7 @@ class BasicFieldsTestPage extends TestPage 'Time' => 'Time', 'TimeHTML5' => 'Time', 'ToggleCompositeTextField1' => 'Varchar', - 'ToggleCompositeDropdownField' => 'Varchar', + 'ToggleCompositeDropdownField' => 'Int', 'Validated' => 'Int', ); @@ -323,13 +323,13 @@ public function getCMSFields() $disabledField = $field->performDisabledTransformation(); $disabledField->setTitle($disabledField->Title() . ' (disabled)'); $disabledField->setName($disabledField->getName() . '_disabled'); - $disabledField->setValue($this->getField($field->getName())); + $disabledField->setValue($field->getValue()); $tabObj->insertAfter($field->getName(), $disabledField); $readonlyField = $field->performReadonlyTransformation(); $readonlyField->setTitle($readonlyField->Title() . ' (readonly)'); $readonlyField->setName($readonlyField->getName() . '_readonly'); - $readonlyField->setValue($this->getField($field->getName())); + $readonlyField->setValue($field->getValue()); $tabObj->insertAfter($field->getName(), $readonlyField); } } diff --git a/code/elemental/ElementContentExtension.php b/code/elemental/ElementContentExtension.php index a517a50..7a162a6 100644 --- a/code/elemental/ElementContentExtension.php +++ b/code/elemental/ElementContentExtension.php @@ -28,7 +28,7 @@ class ElementContentExtension extends Extension 'MyFile' => File::class, ]; - protected function updatevalidate(ValidationResult $result) + protected function updateValidate(ValidationResult $result) { if ($this->owner->Title == 'x') { $result->addFieldError('Title', 'Title cannot be x'); diff --git a/code/elemental/NumericFieldExtension.php b/code/elemental/NumericFieldExtension.php index 358c8e8..fd8e421 100644 --- a/code/elemental/NumericFieldExtension.php +++ b/code/elemental/NumericFieldExtension.php @@ -4,16 +4,17 @@ use SilverStripe\Forms\NumericField; use SilverStripe\Core\Extension; +use SilverStripe\Core\Validation\ValidationResult; /** * @extends Extension */ class NumericFieldExtension extends Extension { - protected function updateValidationResult($result, $validator) + protected function updateValidate(ValidationResult $result) { if ($this->owner->Value() == 1) { - $validator->validationError($this->owner->getName(), 'This field cannot be 1'); + $result->addFieldError($this->owner->getName(), 'This field cannot be 1'); } } }