Quantcast
Channel: Drupal Blog
Viewing all articles
Browse latest Browse all 10

Create a config form in Drupal 8

$
0
0
In Drupal 7, to manage system variables, we used variable_get() / variable_set() /  variable_del() calls and stored those variables in the variable table of the database.

In Drupal 8 we now use the Configuration system which provides a central place for modules to store configuration data. This system allows to store information that can be synchronized between development and production sites. This information is often created during site building and is not typically generated by regular users during normal site operation.
In Drupal 8 configuration is still stored in the database,  but it can now be synced with YML files on the disk for deployment purposes aswell.

In this post we will create a configuration form that stores a configuration value in our system. In this case it will be a form that stores the value of an external API key. Next, we will retrieve this value and use it in a very simple controller.

1. Create the module
2. Create the form
3. Check the form
4. Retrieve the config information in a controller

1. Create the module skeleton

We use the following Drupal Console command.

Viewing all articles
Browse latest Browse all 10

Trending Articles