How to do it...

  1. In your module's directory, create a config directory, and then create a directory inside it named install.
  1. Create a file named drupalform.schema.yml . This file will tell Drupal about the configuration item that we want to save.
  1. Add the following configuration schema definition to drupalform.schema.yml:
  drupalform.company: 
    type: config_object 
    label: 'Drupal form settings' 
    mapping: 
      company_name: 
        type: string 
        label: 'A company name' 

This tells Drupal that we have the configuration with the name drupalform.company, and it has a valid option of company_name. We will cover this in more detail in Chapter 9, Configuration Management - Deploying in Drupal 8.

  1. Next, edit the module's src/Form/ExampleForm.php file. Replace ...

Get Drupal 8 Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.