Modules frequently need to create forms to collect module specific configuration, since this is a common task Drupal provides a set of helper classes and APIs to make this process easier.
This course covers the basics of defining a settings form, retrieving and setting configuration values, and saving configuration data. You will also learn how to add configuration settings to themes and provide administrators with more control over the theme's behavior.
Key topics
- Creating a settings form in a module
- Retrieving and setting configuration values in a form
- Loading and saving configuration entity data
- Customizing the theme settings form in code
- Using the Configuration API to manage module settings
- Providing default configuration values and managing configuration synchronization
- Practical examples of settings forms and configuration management
As a developer, within a module, you can define settings for the module and provide a configuration form for administrators to update the values of those settings. In this tutorial, we'll create a configuration settings form for a module and define default values for each setting. We'll use Drupal Console, a command-line utility for Drupal to do some code scaffolding and speed up the process.
By the end of this lesson, you should be able to get a basic settings form up and running inside a custom module complete with default settings and a menu link.
In Drupal's Appearance UI, all themes get a theme settings form. As a theme developer, you can customize the theme settings form, enabling site administrators to have more control over the appearance of the theme.
In this tutorial, we'll show you how to add admin-configurable settings to your theme. In the process of doing this, we'll use a variety of theme and module development skills and assume you have some familiarity with using Drupal's Form API, Configuration API, and theme system (see Prerequisites).
By the end of this tutorial, you will be able to provide custom theme settings that an administrator can use to modify the appearance of the theme.