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.
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 for a node type named story. It is assumed that these images are available as save.png
and preview.png
, and stored in the mysite module's images
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/7#image_button.