mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Validator/RequiredFields should not regard "0" as an empty value (from r108512)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112756 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
b2c7c944de
commit
c0e2017cfc
@ -123,7 +123,7 @@ class CustomRequiredFields extends RequiredFields{
|
||||
eval($fieldName['php']);
|
||||
}else if($formField) {
|
||||
// if an error is found, the form is returned.
|
||||
if(!$data[$fieldName] || preg_match('/^\s*$/', $data[$fieldName])) {
|
||||
if(!strlen($data[$fieldName]) || preg_match('/^\s*$/', $data[$fieldName])) {
|
||||
$this->validationError(
|
||||
$fieldName,
|
||||
sprintf(_t('Form.FIELDISREQUIRED', "%s is required."),
|
||||
|
@ -99,8 +99,8 @@ JS;
|
||||
}
|
||||
if($this->required) {
|
||||
foreach($this->required as $fieldName) {
|
||||
$formField = $fields->dataFieldByName($fieldName);
|
||||
if($formField && !$data[$fieldName]) {
|
||||
$formField = $fields->dataFieldByName($fieldName);
|
||||
if($formField && !strlen($data[$fieldName])) {
|
||||
$errorMessage = sprintf(_t('Form.FIELDISREQUIRED', '%s is required').'.', strip_tags('"' . ($formField->Title() ? $formField->Title() : $fieldName) . '"'));
|
||||
if($msg = $formField->getCustomValidationMessage()) {
|
||||
$errorMessage = $msg;
|
||||
|
@ -167,7 +167,7 @@ abstract class Validator extends Object {
|
||||
}
|
||||
|
||||
function requireField($fieldName, $data) {
|
||||
if(!$data[$fieldName]) $this->validationError($fieldName, "$fieldName is required.", "required");
|
||||
if(!strlen($data[$fieldName])) $this->validationError($fieldName, "$fieldName is required.", "required");
|
||||
}
|
||||
|
||||
function includeJavascriptValidation() {
|
||||
|
Loading…
Reference in New Issue
Block a user