Module Development

Movie Project: Create an Administration Form for Drupal 7

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Create an administration form to save information about how the movie importer works by using variables.

Goal

Create an administrative configuration form and use those values in variables with a custom module.

Prerequisites

You will need the following knowledge and skills. If you need a review, check out the Additional resources section at the bottom of this page.

  1. Create administration forms to set variables within Drupal.
  2. Use variables where appropriate within custom modules.

Tasks

Create a menu hook to load an administration form. The form should be in a new file that has the sole purpose of containing the definition of a configuration form.

Allow the user to set the API URL as a variable, which is then used with the request made to the API.

Create an update hook to set the default variable of the API URL.

Recap

  • Forms are often used to manage configuration settings for modules, and are often kept separate from the main functionality of a module.
  • Update hooks are used to manage changes in configuration.

Further your understanding

Additional resources

Creative Commons License

Drupal Training Resources by Damian Robinson are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at http://www.damianrobinson.co.uk.

Hands-On Exercises: Movie Project