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.

Best practices for hook_form_alter()

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:02
    Best Practices for hook_form_alter()
  • 0:05
    with Joe Shindelar
  • 0:07
    In this chapter, we're
  • 0:09
    going to take a look at some other things
  • 0:10
    we can do by implementing hook_form_alter
  • 0:12
    inside of our theme.
  • 0:14
    We're also going to look at alternate ways
  • 0:16
    for implementing hook_form_alter.
  • 0:17
    And finally, we'll look at some things that probably shouldn't
  • 0:21
    be done inside of a theme.

Best Practices for hook_form_alter()

Loading...

The ability of having alter hooks within the theme layer starts to blur the line between the logic and presentation, and so there are a few things to be aware of when using hook_form_alter() from the theme layer. The biggest thing to know is that the form rendering process has already gone through the creation and validation preparation process at the module layer, and so you shouldn't be drastically changing the functionality of a form at the theme layer. This form alter hook at the theme layer is primarily for aesthetic clean-up, styling and additional design. This chapter gives some specific examples of things to watch out for.

Additional resources: