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.
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.

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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;
}

View File

@ -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)) {

View File

@ -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

View File

@ -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);

View File

@ -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) {

View File

@ -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!#$%&\'*+/=?^_`{|}~-]+)*'

View File

@ -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];

View File

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

View File

@ -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;
}

View File

@ -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;

View File

@ -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

View File

@ -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));
}
}

View File

@ -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;
}

View File

@ -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)

View File

@ -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;

View File

@ -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();