Skip to content

Commit

Permalink
Merge pull request #209 from creative-commoners/pulls/2/form-field-valid
Browse files Browse the repository at this point in the history
API Rename method
  • Loading branch information
GuySartorelli authored Dec 2, 2024
2 parents 7547c93 + dd062f3 commit 86d5528
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions code/BasicFieldsTestPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -70,7 +70,7 @@ class BasicFieldsTestPage extends TestPage
'Time' => 'Time',
'TimeHTML5' => 'Time',
'ToggleCompositeTextField1' => 'Varchar',
'ToggleCompositeDropdownField' => 'Varchar',
'ToggleCompositeDropdownField' => 'Int',
'Validated' => 'Int',
);

Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion code/elemental/ElementContentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 3 additions & 2 deletions code/elemental/NumericFieldExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

use SilverStripe\Forms\NumericField;
use SilverStripe\Core\Extension;
use SilverStripe\Core\Validation\ValidationResult;

/**
* @extends Extension<NumericField>
*/
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');
}
}
}

0 comments on commit 86d5528

Please sign in to comment.