From 9e8a5c9ba557298eed319744d3cc5689483063ab Mon Sep 17 00:00:00 2001 From: Stevie Mayhew Date: Mon, 11 May 2015 12:32:00 +1200 Subject: [PATCH] FIX: remove validation type constraint from form fields for 3.2 release --- docs/en/04_Changelogs/3.2.0.md | 1 - forms/CheckboxSetField.php | 2 +- forms/CompositeField.php | 2 +- forms/ConfirmedPasswordField.php | 2 +- forms/CreditCardField.php | 2 +- forms/CurrencyField.php | 2 +- forms/DateField.php | 2 +- forms/DatetimeField.php | 2 +- forms/DropdownField.php | 2 +- forms/EmailField.php | 2 +- forms/FileField.php | 2 +- forms/FormField.php | 2 +- forms/GroupedDropdownField.php | 2 +- forms/ListboxField.php | 2 +- forms/MemberDatetimeOptionsetField.php | 2 +- forms/MoneyField.php | 2 +- forms/NumericField.php | 2 +- forms/PhoneNumberField.php | 2 +- forms/TimeField.php | 2 +- forms/UploadField.php | 2 +- 20 files changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/en/04_Changelogs/3.2.0.md b/docs/en/04_Changelogs/3.2.0.md index 8658bc785..2820e5cfe 100644 --- a/docs/en/04_Changelogs/3.2.0.md +++ b/docs/en/04_Changelogs/3.2.0.md @@ -459,5 +459,4 @@ coding conventions. E.g. `DB::requireTable` is now `DB::require_table` * create_table_options now uses constants as API specific filters rather than strings. This is in order to promote better referencing of elements across the codebase. See `FulltextSearchable->enable` for example. - * `FormField` subclasses must now use `validate(Validator $validator)` as the interface has changed for this function * `$FromEnd` iterator variable now available in templates. diff --git a/forms/CheckboxSetField.php b/forms/CheckboxSetField.php index 925e6ea09..e898435fb 100644 --- a/forms/CheckboxSetField.php +++ b/forms/CheckboxSetField.php @@ -318,7 +318,7 @@ class CheckboxSetField extends OptionsetField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator) { + public function validate($validator) { $values = $this->value; if (!$values) { return true; diff --git a/forms/CompositeField.php b/forms/CompositeField.php index 24c2bd53a..4b5f8bf3d 100644 --- a/forms/CompositeField.php +++ b/forms/CompositeField.php @@ -365,7 +365,7 @@ class CompositeField extends FormField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator) { + public function validate($validator) { $valid = true; foreach($this->children as $idx => $child){ $valid = ($child && $child->validate($validator) && $valid); diff --git a/forms/ConfirmedPasswordField.php b/forms/ConfirmedPasswordField.php index cca24ee42..e6a8c6f45 100644 --- a/forms/ConfirmedPasswordField.php +++ b/forms/ConfirmedPasswordField.php @@ -319,7 +319,7 @@ class ConfirmedPasswordField extends FormField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator) { + public function validate($validator) { $name = $this->name; // if field isn't visible, don't validate diff --git a/forms/CreditCardField.php b/forms/CreditCardField.php index 0fc0d54c4..5c80dd9f3 100644 --- a/forms/CreditCardField.php +++ b/forms/CreditCardField.php @@ -58,7 +58,7 @@ class CreditCardField extends TextField { else return $this->value; } - public function validate(Validator $validator){ + public function validate($validator){ if(!$this->value || !trim(implode("", $this->value))) { return true; } diff --git a/forms/CurrencyField.php b/forms/CurrencyField.php index 9b3a8b19b..568f5907f 100644 --- a/forms/CurrencyField.php +++ b/forms/CurrencyField.php @@ -43,7 +43,7 @@ class CurrencyField extends TextField { return $this->castedCopy('CurrencyField_Readonly'); } - public function validate(Validator $validator) { + public function validate($validator) { if(!empty ($this->value) && !preg_match('/^\s*(\-?\$?|\$\-?)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*$/', $this->value)) { diff --git a/forms/DateField.php b/forms/DateField.php index 0ceca0101..20b0597c7 100644 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -336,7 +336,7 @@ class DateField extends TextField { /** * @return Boolean */ - public function validate(Validator $validator) { + public function validate($validator) { $valid = true; // Don't validate empty fields diff --git a/forms/DatetimeField.php b/forms/DatetimeField.php index 0340535db..9574621d5 100644 --- a/forms/DatetimeField.php +++ b/forms/DatetimeField.php @@ -323,7 +323,7 @@ class DatetimeField extends FormField { } } - public function validate(Validator $validator) { + public function validate($validator) { $dateValid = $this->dateField->validate($validator); $timeValid = $this->timeField->validate($validator); diff --git a/forms/DropdownField.php b/forms/DropdownField.php index a5ac2d099..d3f990a6c 100644 --- a/forms/DropdownField.php +++ b/forms/DropdownField.php @@ -312,7 +312,7 @@ class DropdownField extends FormField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator) { + public function validate($validator) { $source = $this->getSourceAsArray(); if (!array_key_exists($this->value, $source)) { if ($this->getHasEmptyDefault() && !$this->value) { diff --git a/forms/EmailField.php b/forms/EmailField.php index f8f0ef614..8e540c0f6 100644 --- a/forms/EmailField.php +++ b/forms/EmailField.php @@ -30,7 +30,7 @@ class EmailField extends TextField { * @param Validator $validator * @return String */ - public function validate(Validator $validator) { + public function validate($validator) { $this->value = trim($this->value); $pcrePattern = '^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*' diff --git a/forms/FileField.php b/forms/FileField.php index b52ef5960..9973144df 100644 --- a/forms/FileField.php +++ b/forms/FileField.php @@ -181,7 +181,7 @@ class FileField extends FormField { return ($this->folderName !== false) ? $this->folderName : Config::inst()->get('Upload', 'uploads_folder'); } - public function validate(Validator $validator) { + public function validate($validator) { if(!isset($_FILES[$this->name])) return true; $tmpFile = $_FILES[$this->name]; diff --git a/forms/FormField.php b/forms/FormField.php index 375beadab..448f5b393 100644 --- a/forms/FormField.php +++ b/forms/FormField.php @@ -922,7 +922,7 @@ class FormField extends RequestHandler { * @param Validator * @return boolean */ - public function validate(Validator $validator) { + public function validate($validator) { return true; } diff --git a/forms/GroupedDropdownField.php b/forms/GroupedDropdownField.php index 0ba6f03e8..500ecfa9e 100644 --- a/forms/GroupedDropdownField.php +++ b/forms/GroupedDropdownField.php @@ -91,7 +91,7 @@ class GroupedDropdownField extends DropdownField { /** * @todo Implement DropdownField::validate() with group validation support */ - public function validate(Validator $validator) { + public function validate($validator) { return true; } diff --git a/forms/ListboxField.php b/forms/ListboxField.php index 7501a0010..1d498b2e5 100644 --- a/forms/ListboxField.php +++ b/forms/ListboxField.php @@ -287,7 +287,7 @@ class ListboxField extends DropdownField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator) { + public function validate($validator) { $values = $this->value; if (!$values) { return true; diff --git a/forms/MemberDatetimeOptionsetField.php b/forms/MemberDatetimeOptionsetField.php index 7219131db..ccca89900 100644 --- a/forms/MemberDatetimeOptionsetField.php +++ b/forms/MemberDatetimeOptionsetField.php @@ -125,7 +125,7 @@ class MemberDatetimeOptionsetField extends OptionsetField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator) { + public function validate($validator) { $value = isset($_POST[$this->name . '_custom']) ? $_POST[$this->name . '_custom'] : null; if(!$value) return true; // no custom value, don't validate diff --git a/forms/MoneyField.php b/forms/MoneyField.php index 9a1009bca..f9daee2b4 100644 --- a/forms/MoneyField.php +++ b/forms/MoneyField.php @@ -184,7 +184,7 @@ class MoneyField extends FormField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator) { + public function validate($validator) { return !(is_null($this->fieldAmount) || is_null($this->fieldCurrency)); } } diff --git a/forms/NumericField.php b/forms/NumericField.php index 4c9c744b4..eb7d70b60 100644 --- a/forms/NumericField.php +++ b/forms/NumericField.php @@ -76,7 +76,7 @@ class NumericField extends TextField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator) { + public function validate($validator) { if(!$this->value) { return true; } diff --git a/forms/PhoneNumberField.php b/forms/PhoneNumberField.php index 2725806e5..0108c307e 100644 --- a/forms/PhoneNumberField.php +++ b/forms/PhoneNumberField.php @@ -134,7 +134,7 @@ class PhoneNumberField extends FormField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator){ + public function validate($validator){ $valid = preg_match( '/^[0-9\+\-\(\)\s\#]*$/', $this->joinPhoneNumber($this->value) diff --git a/forms/TimeField.php b/forms/TimeField.php index 703688e31..0dc023274 100644 --- a/forms/TimeField.php +++ b/forms/TimeField.php @@ -165,7 +165,7 @@ class TimeField extends TextField { * @param Validator $validator * @return bool */ - public function validate(Validator $validator) { + public function validate($validator) { // Don't validate empty fields if(empty($this->value)) return true; diff --git a/forms/UploadField.php b/forms/UploadField.php index d76da42d8..d09a6379f 100644 --- a/forms/UploadField.php +++ b/forms/UploadField.php @@ -985,7 +985,7 @@ class UploadField extends FileField { * @param Validator $validator * @return boolean */ - public function validate(Validator $validator) { + public function validate($validator) { $name = $this->getName(); $files = $this->getItems();