diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-08-10 10:51:17 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-08-10 10:51:17 +0000 |
commit | 87bdc95bff527771e82986fdfb96b2d0e9a4af99 (patch) | |
tree | 4584c1e2007f9da280a89d71d302d2b5202a4148 /includes | |
parent | cf83099de10350adbd7868f729699e199a8d55c1 (diff) | |
download | brdo-87bdc95bff527771e82986fdfb96b2d0e9a4af99.tar.gz brdo-87bdc95bff527771e82986fdfb96b2d0e9a4af99.tar.bz2 |
#165013 by Eaton: fix image button behaviour by processing the right values coming in the request
Diffstat (limited to 'includes')
-rw-r--r-- | includes/form.inc | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/includes/form.inc b/includes/form.inc index 6001c51c8..2392184d5 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -948,6 +948,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. * * @param $form @@ -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"; } |