Check your version

This tutorial 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.

Last updated June 7, 2017

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

Objectives and Prerequisites

You will need the following knowledge and skills. If you need a review, check out the 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.

Summary

  • 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.

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.