Skip to content

Commit

Permalink
FIX: remove validation type constraint from form fields for 3.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
stevie-mayhew committed May 11, 2015
1 parent f275076 commit 9e8a5c9
Show file tree
Hide file tree
Showing 20 changed files with 19 additions and 20 deletions.
1 change: 0 additions & 1 deletion docs/en/04_Changelogs/3.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion forms/CheckboxSetField.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function ExtraOptions() {
* @param Validator $validator
* @return bool
*/
public function validate(Validator $validator) {
public function validate($validator) {
$values = $this->value;
if (!$values) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion forms/CompositeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public function debug() {
* @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);
Expand Down
2 changes: 1 addition & 1 deletion forms/ConfirmedPasswordField.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function isSaveable() {
* @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
Expand Down
2 changes: 1 addition & 1 deletion forms/CreditCardField.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function dataValue() {
else return $this->value;
}

public function validate(Validator $validator){
public function validate($validator){
if(!$this->value || !trim(implode("", $this->value))) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion forms/CurrencyField.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function performReadonlyTransformation() {
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)) {

Expand Down
2 changes: 1 addition & 1 deletion forms/DateField.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public static function set_default_config($k, $v) {
/**
* @return Boolean
*/
public function validate(Validator $validator) {
public function validate($validator) {
$valid = true;

// Don't validate empty fields
Expand Down
2 changes: 1 addition & 1 deletion forms/DatetimeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public function getConfig($name = null) {
}
}

public function validate(Validator $validator) {
public function validate($validator) {
$dateValid = $this->dateField->validate($validator);
$timeValid = $this->timeField->validate($validator);

Expand Down
2 changes: 1 addition & 1 deletion forms/DropdownField.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public function getSourceAsArray()
* @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) {
Expand Down
2 changes: 1 addition & 1 deletion forms/EmailField.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getAttributes() {
* @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!#$%&\'*+/=?^_`{|}~-]+)*'
Expand Down
2 changes: 1 addition & 1 deletion forms/FileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function getFolderName() {
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];
Expand Down
2 changes: 1 addition & 1 deletion forms/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ public function createTag($tag, $attributes, $content = null) {
* @param Validator
* @return boolean
*/
public function validate(Validator $validator) {
public function validate($validator) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion forms/GroupedDropdownField.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function Type() {
/**
* @todo Implement DropdownField::validate() with group validation support
*/
public function validate(Validator $validator) {
public function validate($validator) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion forms/ListboxField.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function getDefaultItems() {
* @param Validator $validator
* @return bool
*/
public function validate(Validator $validator) {
public function validate($validator) {
$values = $this->value;
if (!$values) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion forms/MemberDatetimeOptionsetField.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function setValue($value) {
* @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

Expand Down
2 changes: 1 addition & 1 deletion forms/MoneyField.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function getLocale() {
* @param Validator $validator
* @return bool
*/
public function validate(Validator $validator) {
public function validate($validator) {
return !(is_null($this->fieldAmount) || is_null($this->fieldCurrency));
}
}
2 changes: 1 addition & 1 deletion forms/NumericField.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function getAttributes() {
* @param Validator $validator
* @return bool
*/
public function validate(Validator $validator) {
public function validate($validator) {
if(!$this->value) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion forms/PhoneNumberField.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function saveInto(DataObjectInterface $record) {
* @param Validator $validator
* @return bool
*/
public function validate(Validator $validator){
public function validate($validator){
$valid = preg_match(
'/^[0-9\+\-\(\)\s\#]*$/',
$this->joinPhoneNumber($this->value)
Expand Down
2 changes: 1 addition & 1 deletion forms/TimeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function dataValue() {
* @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;
Expand Down
2 changes: 1 addition & 1 deletion forms/UploadField.php
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ public function Field($properties = array()) {
* @param Validator $validator
* @return boolean
*/
public function validate(Validator $validator) {
public function validate($validator) {
$name = $this->getName();
$files = $this->getItems();

Expand Down

0 comments on commit 9e8a5c9

Please sign in to comment.