Replacing a standard submit button with an image button
Design requirements sometimes dictate that standard form buttons be replaced with image equivalents. In this recipe, we will be replacing the Save and Preview buttons in node creation forms with image buttons.
Getting ready
We will be using the mysite module created earlier in this book. We will be adding two image buttons—one for Save and the other for the Preview button—to the form. It is assumed that these images are available as save.png
and preview.png
, and stored in the myzen theme's image
folder.
It is also worthwhile familiarizing ourselves with the syntax and general vagaries of the button, image_button
, and submit
form element types via the Form API reference manual at http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#image_button.
How to do it...
Since we are altering forms, we will be performing the following steps in the mysite module as follows:
Browse to the mysite module folder at
sites/all/modules...