Drupal architect, LAMP developer, and open source advocate. Spends free (?) time drinking coffee, enjoying good beer, good music, rollerskating and running around with three awesome little girls.
This is a pretty simple task but one I seem to end up doing over and over again for whatever project I'm working on at the time. I've done it a number of ways, from simply using CSS and dealing with multiple cross-browser issues, and probably quite a few alterations of this technique.
In our custom module we're going to need a couple functions. First, we need to use hook_elements to define our new image element.
Next, we need to theme our new type of element, which is called image_button above.
function theme_image_button($element) {
return '\n";
}
?>
This is a very similar to Drupal's core theme_button function.
This function is needed to ensure the default_value doesn't get moved to #value. This should solve the issue with multiple submit buttons some browsers have.
function image_button_value() {
// null value to guarantee default_value doesn't get moved to #value }
?>
Next, we need to use our trusty old hook_form_alter for the submit button of our choice.