Check your version

This video covers a topic in Drupal 7 which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of Drupal 7, but we consider it archived.

Altering forms from the theme layer

Video loading...

Join Drupalize.Me to watch this video

Join today and gain instant access to our entire video library.

Log in Sign up
  • 0:03
    Altering Forms from the Theme Layer
  • 0:06
    with Joe Shindelar
  • 0:08
    In this chapter, I want to take a look
  • 0:09
    at implementing one more hook.
  • 0:12
    Of the four hooks that we can implement inside of a theme,
  • 0:14
    the last one is hook_form_alter.
  • 0:17
    hook_form_alter is a really powerful function inside of Drupal
  • 0:21
    that has historically allowed modules
  • 0:23
    to make changes to any form provided by any other module in Drupal.
  • 0:28
    So for example, the Search module can provide

Altering Forms from the Theme Layer


This chapter gives an introduction to how you work with Drupal's renderable, form arrays by adding an image button to the search form. It also walks through the process of adding the necessary classes to a form element so that the image button is properly aligned. The Forms API reference document is a pretty essential reference document for creating and editing forms in Drupal.

Although we use the function dsm() in this video, this should probably be dpm() as that's the preferred function name. The functions dsm() and dpm() are identical.

Additional resources: