Form Alterations

7
June 28, 2009 Form Alterations - Getting What You Want in Drupal Without Hacking Presented by Mark W. Jarrell Drupal/Twitter username: attheshow Http://fleetthought.com Sunday, June 28, 2009

description

Shows how to use hook_form_alter. This goes with a DrupalCamp Colorado 09 session.

Transcript of Form Alterations

Page 2: Form Alterations

What are we talking about?

✤ This is a “how to” session

✤ Modify form elements in Drupal created by either core modules or contributed modules you’ve installed

Sunday, June 28, 2009

Page 3: Form Alterations

Why do we need to alter forms?

✤ Custom functionality for our sites

✤ Gives us more control over how things appear in our forms

✤ Can be used to increase efficiency for users entering things into Drupal’s forms

✤ Example: Prepopulating the domain part of the email address for our admin who’s adding new users.

Sunday, June 28, 2009

Page 4: Form Alterations

Why not just hack it?

✤ Maintaining something that’s hacked is difficult.

✤ When you upgrade, you may lose your changes.

✤ Other community members can help you because your system conforms to Drupal standards.

Sunday, June 28, 2009

Page 5: Form Alterations

What do we need to make it happen?

✤ Devel modulehttp://drupal.org/project/devel

✤ Gives us a great function for inspecting forms (dsm())

✤ Build a custom module

✤ We’ll call ours “dcc09”

Sunday, June 28, 2009

Page 6: Form Alterations

Demo

Sunday, June 28, 2009

Page 7: Form Alterations

Further Reading Links

✤ “Modifying Forms in Drupal 5 and 6”http://www.lullabot.com/articles/modifying-forms-5-and-6

✤ hook_form_alter() functionhttp://api.drupal.org/api/function/hook_form_alter/6

✤ The D6 Form API (a.k.a. FAPI) quickstarthttp://api.drupal.org/api/file/developer/topics/forms_api.html/6

✤ Form API referencehttp://api.drupal.org/api/file/developer/topics/forms_api_reference.html/6

Photo On Intro Slide: Http://is.gd/17yFt

Sunday, June 28, 2009