[development] image button form element module?

Nedjo Rogers nedjo at islandnet.com
Sat Jul 8 14:36:24 UTC 2006


> Anyone written an image button form element module?

For Goodstorm we tried using image inputs for form submission, but abandoned 
the approach. It seemed like a misuse of the image input type, which is 
intended to pass an x,y coordinate. This is the code we used.

/**
 * Format an image input.
 *
 * This element type is used to substitute a graphic for a regular form 
submit button.
 *
 * @param $element
 *   An associative array containing the properties of the element.
 * @return
 *   A themed HTML string representing the image input.
 */
function theme_select_image($element) {
  return '<input type="image" '. (empty($element['#name']) ? '' : 'name="'. 
$element['#name'] .'" ') .'value="'. check_plain($element['#value']) .'" '. 
drupal_attributes($element['#attributes']) ." />\n";
}

// Sample usage.
$form['submit'] = array(
  '#type' => 'submit_image',
  '#value' => t('Submit'),
  '#name'=> 'submit',
  '#attributes' => array('src' => 'path/to/image.png')
); 



More information about the development mailing list