Commit 92f647fb authored by Stacey Walker's avatar Stacey Walker
Browse files

submitcancel element can have items entered by string or numeric indices


    - this makes it possible to reverse the order in which they display
      (bug: 619266)
Signed-off-by: default avatarStacey Walker <stacey@catalyst.net.nz>
parent 8b0b467c
...@@ -38,6 +38,31 @@ function pieform_element_submitcancel(Pieform $form, $element) {/*{{{*/ ...@@ -38,6 +38,31 @@ function pieform_element_submitcancel(Pieform $form, $element) {/*{{{*/
} }
$form->include_plugin('element', 'submit'); $form->include_plugin('element', 'submit');
$form->include_plugin('element', 'cancel'); $form->include_plugin('element', 'cancel');
$elems = '';
foreach ($element['value'] as $key => $value) {
if (!is_numeric($key)) {
$function = 'pieform_element_' . $key;
if (function_exists($function)) {
$item = $element;
$item['class'] = isset($element['class']) ? $element['class'] . ' ' . $key : $key;
$item['value'] = $element['value'][$key];
if (isset($element['confirm']) && isset($element['confirm'][$key])) {
$item['confirm'] = $element['confirm'][$key];
}
else {
unset($item['confirm']);
}
$elems .= $function($form, $item);
$elems .= ' ';
}
}
}
if (!empty($elems)) {
return $elems;
}
$submitelement = $element; $submitelement = $element;
$submitelement['class'] = (isset($submitelement['class'])) ? $submitelement['class'] . ' submit' : 'submit'; $submitelement['class'] = (isset($submitelement['class'])) ? $submitelement['class'] . ' submit' : 'submit';
$submitelement['value'] = $element['value'][0]; $submitelement['value'] = $element['value'][0];
...@@ -66,7 +91,12 @@ function pieform_element_submitcancel_set_attributes($element) {/*{{{*/ ...@@ -66,7 +91,12 @@ function pieform_element_submitcancel_set_attributes($element) {/*{{{*/
function pieform_element_submitcancel_get_value(Pieform $form, $element) {/*{{{*/ function pieform_element_submitcancel_get_value(Pieform $form, $element) {/*{{{*/
if (is_array($element['value'])) { if (is_array($element['value'])) {
return $element['value'][0]; if (isset($element['value']['submit'])) {
return $element['value']['submit'];
}
else {
return $element['value'][0];
}
} }
else { else {
return $element['value']; return $element['value'];
......
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