Commit 5eb99862 authored by Nigel McNie's avatar Nigel McNie
Browse files

Apply pieforms patch for handling form submission when multiple forms are on the page.

This might be dangerous, not applying to trunk/stable yet.
parent 1c2d8028
......@@ -716,7 +716,7 @@ class Pieform {/*{{{*/
if (isset($element['value'])) {
return $element['value'];
}
else if (isset($global[$element['name']]) && $element['type'] != 'submit') {
else if ($this->submitted && isset($global[$element['name']]) && $element['type'] != 'submit') {
return $global[$element['name']];
}
else if (isset($element['defaultvalue'])) {
......
......@@ -126,7 +126,7 @@ function pieform_element_calendar_get_value(Pieform $form, $element) {/*{{{*/
return $element['value'];
}
if (isset($global[$name])) {
if ($form->is_submitted() && isset($global[$name])) {
if (trim($global[$name]) == '') {
return null;
}
......
......@@ -116,7 +116,7 @@ EOF;
function pieform_element_date_get_value(Pieform $form, $element) {/*{{{*/
$name = $element['name'];
$global = ($form->get_property('method') == 'get') ? $_GET : $_POST;
if ( isset($global[$name . '_day']) && isset($global[$name . '_month']) && isset($global[$name . '_year']) ) {
if ($form->is_submitted() && isset($global[$name . '_day']) && isset($global[$name . '_month']) && isset($global[$name . '_year'])) {
$time = mktime(0, 0, 0, $global[$name . '_month'], $global[$name . '_day'], $global[$name . '_year']);
if (false === $time) {
return null;
......
......@@ -54,7 +54,7 @@ function pieform_element_image_get_value(Pieform $form, $element) {/*{{{*/
}
$global = $form->get_property('method') == 'get' ? $_GET : $_POST;
if (isset($global[$element['name'] . '_x'])) {
if ($form->is_submitted() && isset($global[$element['name'] . '_x'])) {
return true;
}
......
......@@ -42,7 +42,7 @@ function pieform_element_password_get_value(Pieform $form, $element) {/*{{{*/
if (isset($global[$element['name']])) {
return $global[$element['name']];
}
if (isset($element['value'])) {
if ($form->is_submitted() && isset($element['value'])) {
return $element['value'];
}
return null;
......
......@@ -136,7 +136,7 @@ function pieform_element_select_get_value(Pieform $form, $element) {/*{{{*/
if (isset($element['value'])) {
$values = (array) $element['value'];
}
else if (isset($global[$element['name']])) {
else if ($form->is_submitted() && isset($global[$element['name']])) {
$values = (array) $global[$element['name']];
}
else if (isset($element['defaultvalue'])) {
......@@ -157,7 +157,7 @@ function pieform_element_select_get_value(Pieform $form, $element) {/*{{{*/
if (isset($element['value'])) {
$values = (array) $element['value'];
}
else if (isset($global[$element['name']])) {
else if ($form->is_submitted() && isset($global[$element['name']])) {
$values = (array) $global[$element['name']];
}
else if (!$form->is_submitted() && isset($element['defaultvalue'])) {
......
......@@ -79,7 +79,7 @@ function pieform_element_textarea_get_value(Pieform $form, $element) {/*{{{*/
}
$global = ($form->get_property('method') == 'get') ? $_GET : $_POST;
if (isset($global[$element['name']])) {
if ($form->is_submitted() && isset($global[$element['name']])) {
return str_replace("\r\n", "\n", $global[$element['name']]);
}
......
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