New Podcast

Posted Tuesday, January 31 at 3:28 pm
  Thomas Turnbull (tom_o_t on drupal.org) and Alan Palazzolo (zzolo on drupal.org) join Mike Anello to talk about their new book from O’Reilly Media, Mapping with Drupal. Mike’s usual co-hosts, Andrew and Ryan, were both unable to participate in the podcast, leaving Thomas and Alan subject to Mike’s long-winded (but extremely interesting by some accounts) questions.
Download Podcast 73
DrupalEasy_ep73_20120131.mp3
Syndicate content

NEWSLETTER

Stay informed on our latest news!

Syndicate content

Testimonial

DrupalEasy is by far on of the best ways to learn Drupal; Mike & Ryan completely immerse you into the complex world that is Drupal. Their easy to understand teaching technique and approach to explaining site administration, in a way any newbie or long time Drupaler can understand, makes the DrupalEasy workshops an important and invaluable experience for anyone who wants to become a Drupalista.

Who are we?

DrupalEasy is the collective expertise of Ryan Price and Michael Anello, who joined forces to provide training and consulting services worldwide. Read all about them and what they can do.

What is Drupal?

Drupal is a free, super-powerful content management system for sites that require information posting and collection, including blogs, forums, videos, photos, and databases of information. We think it is the best platform available. Here's why...

Why Drupal?

More and more savvy organizations are going with Drupal for content management, and its no mystery why. It’s free, flexible, and easy to maintain for small or large volume sites. Learn more...

Theming Submit Buttons

Need an fast way to theme a submit button on your site? Using one hook_form_alter() function and some simple CSS, it's fairly easy to do.

The method below actually keeps the text of the button as text and not part of the image (this allows you to reuse the button image for multiple buttons), but you can just as easily set the #value attribute to '' to get rid of the text.

You'll use hook_form_alter() to simply add a CSS class to the button you want to theme and to modify the text of the button.

function mymodule_form_alter(&$form, $form_state, $form_id) {
if ($form_id == 'the_form_im_interested_in_form') {
$form['submit']['#value'] = 'Add Classes';
$form['submit']['#attributes'] = array('class' => 'make_me_an_image_button');
}
return;
}

Next up is some CSS that modifies the way the button looks. Be sure that your button's image is wide enough to handle the longest piece of text you might throw at it:


input.make_me_an_image_button {
background: transparent url(../images/super_button_image.png) no-repeat scroll left top;
color: #FFFFFF;
font-size: 1.2em;
font-weight: bold;
text-decoration: none;
display: block;
padding: 0;
margin: 0;
text-align: center;
border: 0;
text-transform: capitalize;
width: 150px;
height: 30px;
}

If you really want to get fancy-schmancy, you can even add a "hover" state to your button as follows:


input.make_me_an_image_button:hover {
background: transparent url(../images/super_button_image_hover.png) no-repeat scroll left top;

}

Trackback URL for this post:

http://drupaleasy.com/trackback/201
No votes yet

More Quicktips


Syndicate content