Commit 052acd58 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Allow for a general form error to be set rather than using empty string errors...


Allow for a general form error to be set rather than using empty string errors on the submit element
Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 93241e73
......@@ -129,8 +129,7 @@ function contactus_validate(Pieform $form, $values) {
if (!empty($emailcontact)) {
$msg .= ' ' . get_string('formerroremail', 'mahara', $emailcontact, $emailcontact);
}
$SESSION->add_error_msg($msg);
$form->set_error('submit', '');
$form->set_error(null, $msg);
}
}
......
......@@ -626,6 +626,9 @@ class Pieform {/*{{{*/
$result .= ' enctype="multipart/form-data"';
}
$result .= '>';
if (!empty($this->error)) {
$result .= '<div class="error">' . $this->error . '</div>';
}
return $result;
}/*}}}*/
......@@ -945,6 +948,10 @@ EOF;
* @throws PieformException If the element could not be found
*/
public function set_error($name, $message) {/*{{{*/
if (is_null($name) && !empty($message)) {
$this->error = $message;
return;
}
foreach ($this->data['elements'] as $key => &$element) {
if ($element['type'] == 'fieldset') {
foreach ($element['elements'] as &$subelement) {
......@@ -975,7 +982,7 @@ EOF;
return true;
}
}
return false;
return isset($this->error);
}/*}}}*/
/**
......
......@@ -302,8 +302,8 @@ function register_validate(Pieform $form, $values) {
if (!empty($emailcontact)) {
$msg .= ' ' . get_string('formerroremail', 'mahara', $emailcontact, $emailcontact);
}
$SESSION->add_error_msg($msg);
$form->set_error('submit', '');
$form->set_error(null, $msg);
return;
}
$institution = $values['institution'];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment