FIX: remove validation type constraint from form fields for 3.2 release

This commit is contained in:
Stevie Mayhew 2015-05-11 12:32:00 +12:00
parent f275076908
commit 9e8a5c9ba5
20 changed files with 19 additions and 20 deletions

View File

@ -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. * 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. This is in order to promote better referencing of elements across the codebase.
See `FulltextSearchable->enable` for example. 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. * `$FromEnd` iterator variable now available in templates.

View File

@ -318,7 +318,7 @@ class CheckboxSetField extends OptionsetField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator) { public function validate($validator) {
$values = $this->value; $values = $this->value;
if (!$values) { if (!$values) {
return true; return true;

View File

@ -365,7 +365,7 @@ class CompositeField extends FormField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator) { public function validate($validator) {
$valid = true; $valid = true;
foreach($this->children as $idx => $child){ foreach($this->children as $idx => $child){
$valid = ($child && $child->validate($validator) && $valid); $valid = ($child && $child->validate($validator) && $valid);

View File

@ -319,7 +319,7 @@ class ConfirmedPasswordField extends FormField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator) { public function validate($validator) {
$name = $this->name; $name = $this->name;
// if field isn't visible, don't validate // if field isn't visible, don't validate

View File

@ -58,7 +58,7 @@ class CreditCardField extends TextField {
else return $this->value; else return $this->value;
} }
public function validate(Validator $validator){ public function validate($validator){
if(!$this->value || !trim(implode("", $this->value))) { if(!$this->value || !trim(implode("", $this->value))) {
return true; return true;
} }

View File

@ -43,7 +43,7 @@ class CurrencyField extends TextField {
return $this->castedCopy('CurrencyField_Readonly'); return $this->castedCopy('CurrencyField_Readonly');
} }
public function validate(Validator $validator) { public function validate($validator) {
if(!empty ($this->value) if(!empty ($this->value)
&& !preg_match('/^\s*(\-?\$?|\$\-?)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*$/', $this->value)) { && !preg_match('/^\s*(\-?\$?|\$\-?)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*$/', $this->value)) {

View File

@ -336,7 +336,7 @@ class DateField extends TextField {
/** /**
* @return Boolean * @return Boolean
*/ */
public function validate(Validator $validator) { public function validate($validator) {
$valid = true; $valid = true;
// Don't validate empty fields // Don't validate empty fields

View File

@ -323,7 +323,7 @@ class DatetimeField extends FormField {
} }
} }
public function validate(Validator $validator) { public function validate($validator) {
$dateValid = $this->dateField->validate($validator); $dateValid = $this->dateField->validate($validator);
$timeValid = $this->timeField->validate($validator); $timeValid = $this->timeField->validate($validator);

View File

@ -312,7 +312,7 @@ class DropdownField extends FormField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator) { public function validate($validator) {
$source = $this->getSourceAsArray(); $source = $this->getSourceAsArray();
if (!array_key_exists($this->value, $source)) { if (!array_key_exists($this->value, $source)) {
if ($this->getHasEmptyDefault() && !$this->value) { if ($this->getHasEmptyDefault() && !$this->value) {

View File

@ -30,7 +30,7 @@ class EmailField extends TextField {
* @param Validator $validator * @param Validator $validator
* @return String * @return String
*/ */
public function validate(Validator $validator) { public function validate($validator) {
$this->value = trim($this->value); $this->value = trim($this->value);
$pcrePattern = '^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*' $pcrePattern = '^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*'

View File

@ -181,7 +181,7 @@ class FileField extends FormField {
return ($this->folderName !== false) ? $this->folderName : Config::inst()->get('Upload', 'uploads_folder'); 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; if(!isset($_FILES[$this->name])) return true;
$tmpFile = $_FILES[$this->name]; $tmpFile = $_FILES[$this->name];

View File

@ -922,7 +922,7 @@ class FormField extends RequestHandler {
* @param Validator * @param Validator
* @return boolean * @return boolean
*/ */
public function validate(Validator $validator) { public function validate($validator) {
return true; return true;
} }

View File

@ -91,7 +91,7 @@ class GroupedDropdownField extends DropdownField {
/** /**
* @todo Implement DropdownField::validate() with group validation support * @todo Implement DropdownField::validate() with group validation support
*/ */
public function validate(Validator $validator) { public function validate($validator) {
return true; return true;
} }

View File

@ -287,7 +287,7 @@ class ListboxField extends DropdownField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator) { public function validate($validator) {
$values = $this->value; $values = $this->value;
if (!$values) { if (!$values) {
return true; return true;

View File

@ -125,7 +125,7 @@ class MemberDatetimeOptionsetField extends OptionsetField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator) { public function validate($validator) {
$value = isset($_POST[$this->name . '_custom']) ? $_POST[$this->name . '_custom'] : null; $value = isset($_POST[$this->name . '_custom']) ? $_POST[$this->name . '_custom'] : null;
if(!$value) return true; // no custom value, don't validate if(!$value) return true; // no custom value, don't validate

View File

@ -184,7 +184,7 @@ class MoneyField extends FormField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator) { public function validate($validator) {
return !(is_null($this->fieldAmount) || is_null($this->fieldCurrency)); return !(is_null($this->fieldAmount) || is_null($this->fieldCurrency));
} }
} }

View File

@ -76,7 +76,7 @@ class NumericField extends TextField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator) { public function validate($validator) {
if(!$this->value) { if(!$this->value) {
return true; return true;
} }

View File

@ -134,7 +134,7 @@ class PhoneNumberField extends FormField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator){ public function validate($validator){
$valid = preg_match( $valid = preg_match(
'/^[0-9\+\-\(\)\s\#]*$/', '/^[0-9\+\-\(\)\s\#]*$/',
$this->joinPhoneNumber($this->value) $this->joinPhoneNumber($this->value)

View File

@ -165,7 +165,7 @@ class TimeField extends TextField {
* @param Validator $validator * @param Validator $validator
* @return bool * @return bool
*/ */
public function validate(Validator $validator) { public function validate($validator) {
// Don't validate empty fields // Don't validate empty fields
if(empty($this->value)) return true; if(empty($this->value)) return true;

View File

@ -985,7 +985,7 @@ class UploadField extends FileField {
* @param Validator $validator * @param Validator $validator
* @return boolean * @return boolean
*/ */
public function validate(Validator $validator) { public function validate($validator) {
$name = $this->getName(); $name = $this->getName();
$files = $this->getItems(); $files = $this->getItems();