mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Added specific border case for array form data in RequiredFields::php() (from r108811)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112767 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
8ced8772aa
commit
b8ee6f6af5
@ -100,10 +100,17 @@ JS;
|
||||
if($this->required) {
|
||||
foreach($this->required as $fieldName) {
|
||||
$formField = $fields->dataFieldByName($fieldName);
|
||||
|
||||
// we need to check if $data[$fieldName] is an array (FileFiled case)
|
||||
if(($formField && $data[$fieldName] == "") ||
|
||||
(is_array($data[$fieldName]) && $data[$fieldName]['name'] == "")) {
|
||||
|
||||
$error = true;
|
||||
// submitted data for file upload fields come back as an array
|
||||
if(is_array($data[$fieldName])) {
|
||||
$error = ($data[$fieldName]) ? false : true;
|
||||
} else {
|
||||
// assume a string or integer
|
||||
$error = (strlen($data[$fieldName])) ? false : true;
|
||||
}
|
||||
|
||||
if($formField && $error) {
|
||||
$errorMessage = sprintf(_t('Form.FIELDISREQUIRED', '%s is required').'.', strip_tags('"' . ($formField->Title() ? $formField->Title() : $fieldName) . '"'));
|
||||
if($msg = $formField->getCustomValidationMessage()) {
|
||||
$errorMessage = $msg;
|
||||
|
Loading…
Reference in New Issue
Block a user