Skip to content

Commit

Permalink
Fix for Validation::typeX() missing causing validation errors - #626
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed May 30, 2016
1 parent 43c0ac2 commit 4fbf432
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Added support for `xx-XX` locale language lookups in `LanguageCodes` class [#854](https://github.com/getgrav/grav/issues/854)
1. [](#bugfix)
* Fix for corner-case redirect logic causing infinite loops and out-of-memory errors
* Fix for saving fields in expert mode that have no `Validation::typeX()` methods [#626](https://github.com/getgrav/grav-plugin-admin/issues/626)
* Detect if user really meant to extend parent blueprint, not another one (fixes old page type blueprints)
* Fixed a bug in `Page::relativePagePath()` when `Page::$name` is not defined

Expand Down
11 changes: 5 additions & 6 deletions system/src/Grav/Common/Data/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ public static function validate($value, array $field)
$type = (string) isset($field['validate']['type']) ? $field['validate']['type'] : $field['type'];
$method = 'type'.strtr($type, '-', '_');

if (!method_exists(__CLASS__, $method)) {
$method = 'typeText';
}

$name = ucfirst(isset($field['label']) ? $field['label'] : $field['name']);
$message = (string) isset($field['validate']['message'])
? $language->translate($field['validate']['message'])
: $language->translate('FORM.INVALID_INPUT', null, true) . ' "' . $language->translate($name) . '"';

$success = self::$method($value, $validate, $field);
if (method_exists(__CLASS__, $method)) {
$success = self::$method($value, $validate, $field);
} else {
$success = true;
}

if (!$success) {
$messages[$field['name']][] = $message;
Expand Down Expand Up @@ -325,7 +325,6 @@ public static function typeSelect($value, array $params, array $field)
* @param array $field Blueprint for the field.
* @return bool True if validation succeeded.
*/

public static function typeNumber($value, array $params, array $field)
{
if (!is_numeric($value)) {
Expand Down

0 comments on commit 4fbf432

Please sign in to comment.