projects
/
ycra.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7ab51f9
)
Add helper to validate multiple fields.
author
Sam White
<webmaster@ycra.org.uk>
Sun, 24 Oct 2021 15:30:49 +0000
(15:30 +0000)
committer
Sam White
<webmaster@ycra.org.uk>
Sun, 24 Oct 2021 15:30:49 +0000
(15:30 +0000)
public_html/includes/form-validation.php
patch
|
blob
|
history
diff --git
a/public_html/includes/form-validation.php
b/public_html/includes/form-validation.php
index 43ab85e041a360563c7068c988de58bd39e26f4f..dfbb8f54cd8eaeb70cf78f1f022fa22dafe9ba4d 100644
(file)
--- a/
public_html/includes/form-validation.php
+++ b/
public_html/includes/form-validation.php
@@
-1,6
+1,15
@@
<?php
require_once('includes/utils.php');
+function require_fields(&$errors, $data, $keys, $names=null) {
+ if (!is_null($names)) {
+ foreach (array_keys($keys) as $i)
+ require_field($errors, $data, $keys[$i], $names[$i]);
+ }
+ else
+ foreach ($keys as $key) require_field($errors, $data, $key);
+}
+
function require_field(&$errors, $data, $key, $name=null) {
if (is_null($name)) $name = key_to_human_text($key);