Commit 87bdc95b authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#165013 by Eaton: fix image button behaviour by processing the right values coming in the request

parent cf83099d
......@@ -947,6 +947,51 @@ function _form_builder_ie_cleanup($form, &$form_state) {
}
}
/**
* Helper function to determine the value for an image button form element.
*
* @param $form
* The form element whose value is being populated.
* @param $edit
* The incoming POST data to populate the form element. If this is FALSE,
* the element's default value should be returned.
* @return
* The data that will appear in the $form_state['values'] collection
* for this element. Return nothing to use the default.
*/
function form_type_image_button_value($form, $edit = FALSE) {
if ($edit !== FALSE) {
if (!empty($edit)) {
// If we're dealing with Mozilla or Opera, we're lucky. It will
// return a proper value, and we can get on with things.
return $form['#return_value'];
}
else {
// Unfortunately, in IE we never get back a proper value for THIS
// form element. Instead, we get back two split values: one for the
// X and one for the Y coordinates on which the user clicked the
// button. We'll find this element in the #post data, and search
// in the same spot for its name, with '_x'.
$post = $form['#post'];
foreach (split('\[', $form['#name']) as $element_name) {
// chop off the ] that may exist.
if (substr($element_name, -1) == ']') {
$element_name = substr($element_name, 0, -1);
}
if (!isset($post[$element_name])) {
if (isset($post[$element_name .'_x'])) {
return $form['#return_value'];
}
return NULL;
}
$post = $array[$element_name];
}
return $form['#return_value'];
}
}
}
/**
* Helper function to determine the value for a checkbox form element.
*
......@@ -1666,7 +1711,7 @@ function theme_image_button($element) {
(!empty($element['#value']) ? ('value="'. check_plain($element['#value']) .'" ') : '') .
'id="' . $element['#id'] . '" ' .
drupal_attributes($element['#attributes']) .
' src="' . base_path() . $element['#image'] . '" ' .
' src="' . base_path() . $element['#src'] . '" ' .
(!empty($element['#title']) ? 'alt="' . check_plain($element['#title']) . '" title="' . check_plain($element['#title']) . '" ' : '' ).
"/>\n";
}
......
......@@ -105,7 +105,7 @@ function system_elements() {
// Inputs
$type['submit'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => TRUE, '#ahah_event' => 'submit', '#process' => array('form_expand_ahah'));
$type['button'] = array('#input' => TRUE, '#name' => 'op', '#button_type' => 'submit', '#executes_submit_callback' => FALSE, '#ahah_event' => 'submit', '#process' => array('form_expand_ahah'));
$type['image_button'] = array('#input' => TRUE, '#button_type' => 'submit','#executes_submit_callback' => TRUE, '#ahah_event' => 'submit', '#process' => array('form_expand_ahah'), '#has_garbage_value' => TRUE, '#image' => NULL);
$type['image_button'] = array('#input' => TRUE, '#button_type' => 'submit','#executes_submit_callback' => TRUE, '#ahah_event' => 'submit', '#process' => array('form_expand_ahah'), '#return_value' => TRUE, '#has_garbage_value' => TRUE, '#src' => NULL);
$type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE);
$type['password'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128);
$type['password_confirm'] = array('#input' => TRUE, '#process' => array('expand_password_confirm'));
......
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