Commit a3919e7f authored by Nigel McNie's avatar Nigel McNie
Browse files

Added callback for the 'replycallback' feature of pieforms, which helps handle...

Added callback for the 'replycallback' feature of pieforms, which helps handle forms that can be submitted by both js and non js better.
parent e97fecdc
......@@ -1094,6 +1094,7 @@ function pieform_configure() {
'requiredmarker' => true,
'elementclasses' => true,
'jsdirectory' => get_config('wwwroot') . 'lib/pieforms/static/core/',
'replycallback' => 'pieform_reply',
'jserrorcallback' => 'formError',
'globaljserrorcallback' => 'formGlobalError',
'jssuccesscallback' => 'formSuccess',
......@@ -1132,6 +1133,23 @@ function pieform_validate(Pieform $form, $values) {
}
}
function pieform_reply($code, $data) {
global $SESSION;
if (isset($data['message'])) {
if ($code == PIEFORM_ERR) {
$SESSION->add_error_msg($data['message']);
}
else {
$SESSION->add_ok_msg($data['message']);
}
}
if (isset($data['goto'])) {
redirect($data['goto']);
}
// NOT explicitly exiting here. Pieforms will throw an exception which will
// force the user to fix their form
}
function pieform_element_calendar_configure($element) {
$element['jsroot'] = get_config('wwwroot') . 'js/jscalendar/';
$element['themefile'] = theme_get_url('style/calendar.css');
......
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