Last active
August 29, 2015 14:15
-
-
Save bmbrands/ac5c81a71a9cc808b346 to your computer and use it in GitHub Desktop.
Alternative validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validation($data, $files) { | |
$errors = parent::validation($data, $files); | |
// Check if any item quantities were selected. | |
// Retrieve order items and amounts. | |
// First assume the user has not selected anything. | |
$allempty = true; | |
// Loop through all of the form fields. | |
foreach ($data as $field => $value) { | |
// filter the select boxes | |
if ($strpos($field, '_type')) { | |
if ($value != 0) { | |
// At least one checkbox was selected. | |
$allempty = false; | |
} | |
// Add an error to each field. | |
$allerrors[$field] = get_string('zeroamount', 'block_realexpayments'); | |
} | |
} | |
// Turns out we all is really empty, return the errors | |
if ($allempty) { | |
return $allerrors; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment