Grayside.Org

Home

drupal8

Overriding Prepopulate: Do Not Use hook_form_FORM_ID_alter

grayside — Fri, 02/12/2010 - 11:31

The Prepopulate module works some great magic to preload forms from URL variables. But suppose you need some extra magic to modify the titles it puts in place?

You can always use hook_form_alter (and here is one of countless little tutorials on that).

If you already know about that, you might be someone that enjoys the use of hook_form_FORM_ID_alter(). If you do, you cannot use it to override Prepopulate-set fields. It turns out that regardless of module weight, hook_form_FORM_ID_alter is called before hook_form_alter for any given form, meaning that the more specific function will always set the value, then Prepopulate will come along and reset it to your URL value.

There is a nice issue (#300481) that details this problem, and hopefully will find itself fixed in Drupal 8.

  • drupal
  • drupal6
  • drupal8
  • hook_form_alter
  • prepopulate
  • Add new comment
  • Read more
Syndicate content

Monthly archive

  • July 2010 (2)
  • June 2010 (6)
  • May 2010 (9)
  • April 2010 (5)
  • March 2010 (6)
more

Feeds

  • Syndicate contentHeadlines
  • Syndicate contentDrupal Planet
  • Syndicate contentAtrium Headlines

casetracker cck drupal features FL3 freelinking module og openatrium permissions plugin spaces
<all>

© 2009 grayside.org ♠ Glossary ♠ Powered by Drupal ♠ Floating on Archlinux