function form_type_image_button_value
7.x form.inc | form_type_image_button_value($form, |
6.x form.inc | form_type_image_button_value($form, $edit = FALSE) |
Helper function to determine the value for an image button form element.
Parameters
$form: The form element whose value is being populated.
$edit: The incoming POST data to populate the form element. If this is FALSE, the element's default value should be returned.
Return value
The data that will appear in the $form_state['values'] collection for this element. Return nothing to use the default.
Related topics
File
- drupal-6.x/
includes/ form.inc, line 1151
Code
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 = $post[$element_name];
}
return $form['#return_value'];
}
}
}