Skip to content

Commit

Permalink
ENH Use FieldValidator for FormFields
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Oct 31, 2024
1 parent 656598a commit 31f0cb9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/StringTagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Control\Controller;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Control\HTTPResponse;
use SilverStripe\Core\Validation\ValidationResult;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\Validator;
use SilverStripe\Model\List\ArrayList;
Expand Down Expand Up @@ -372,13 +373,11 @@ protected function getTags($term)
/**
* DropdownField assumes value will be a scalar so we must
* override validate. This only applies to Silverstripe 3.2+
*
* @param Validator $validator
* @return bool
*/
public function validate($validator)
public function validate(): ValidationResult
{
return $this->extendValidationResult(true, $validator);
// return $this->extendValidationResult(true, $validator);
return new ValidationResult;
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/TagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use SilverStripe\ORM\Relation;
use SilverStripe\Model\List\SS_List;
use SilverStripe\Model\ArrayData;
use SilverStripe\Core\Validation\ValidationResult;

/**
* Provides a tagging interface, storing links between tag DataObjects and a parent DataObject.
Expand Down Expand Up @@ -566,13 +567,12 @@ protected function getTags($term)
/**
* DropdownField assumes value will be a scalar so we must
* override validate. This only applies to Silverstripe 3.2+
*
* @param Validator $validator
* @return bool
*/
public function validate($validator)
public function validate(): ValidationResult
{
return $this->extendValidationResult(true, $validator);
// TODO: temporary code
return new ValidationResult;
// return $this->extendValidationResult(true, $validator);
}

/**
Expand Down

0 comments on commit 31f0cb9

Please sign in to comment.