O'Reilly logo

Drupal 7 Theming Cookbook by Karthik Kumar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding class attributes to form elements

Drupal 7 is quite meticulous with its forms and other markup when it comes to assigning CLASS and ID attributes. This ensures that various page elements can be individually targeted either via CSS or JavaScript and thereby, manipulated as necessary. This is however, not true all the time and circumstances sometimes require further customization.

In this recipe, we will assign class attributes to the Search module's textfields and use them along with a pinch of jQuery to improve usability in situations where the search block is concurrently visible along with the module's input form on the search page.

Getting ready

We will be using the mysite module created earlier in this book to hold an implementation of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required