Commit 0ba3870e authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Added support for differently named submit functions based on the name of

the submit button pressed.
parent 68672660
......@@ -556,7 +556,17 @@ class Pieform {
// Submit the form if things went OK
if ($this->submit && !$this->has_errors()) {
if (function_exists($this->submitfunction)) {
foreach ($this->get_elements() as $element) {
// @todo Rename 'ajaxmessages' to 'submitelement'
if ($element['ajaxmessages'] == true && isset($values[$element['name']])) {
$function = "{$this->name}_submit_{$element['name']}";
if (function_exists($function)) {
$function($values);
break;
}
}
}
else if (function_exists($this->submitfunction)) {
$function = $this->submitfunction;
// Call the user defined function for processing a submit
// This function should really redirect/exit after it has
......
......@@ -42,6 +42,8 @@ function pieform_render_submitcancel($element, Pieform $form) {
}
function pieform_render_submitcancel_set_attributes($element) {
// @todo change to 'submitelement' => true, more generic and can be used
// for working out which submit button was pressed
$element['ajaxmessages'] = true;
return $element;
}
......
Supports Markdown
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