Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Varbase FAQs 9.2.1 Minor update available for module varbase_faqs (9.2.1). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Schema Form

1 sites Security covered
View on drupal.org

This module automatically generates Drupal forms directly from schema definitions, allowing you to create configuration pages and other forms without writing custom PHP code. You simply describe the data structure in a YAML file, and the module builds the form with validation, with options for further customization.

This module automatically generates Drupal Forms directly from defined schemas, using the structure, labels and validation constraints from the schema definition.

It auto generates forms for configuration entities, config objects like module settings page, and for any other schema you want!

Simply put, to create a form page, you should only describe the data schema in a YAML schema file, and that's it. The form page will be generated automatically without custom code at all. But, if you need, you still can alter the form and add your customizations automatically over auto-generated form.

Schema Form Designs

You can customize the form by adding and overriding the schema data using the Schema Form Design entities, without modifying the data schema itself.

Examples

Here are some short examples:

Configuration form (API settings form)

file config/schema/my_module.schema.yml:

my_module.my_api_settings:
 type: config_object
 label: My API Settings
 mapping:
   endpoint:
     type: string
     label: Endpoint URL
     description: URL of the my-api.com endpoint.
   access_token:
     type: string
     label: Access Token
     description: An alphanumeric string 32 characters long.

file my_module.routing.yml:

my_module.my_api_settings:
 path: '/admin/config/system/my-api'
 defaults:
   _form: 'Drupal\schema_form\SchemaConfigFromRouteForm'
   _title: 'My API Settings'
 requirements:
   _permission: 'administer site configuration'
 options:
   editable_config_names:
     - my_module.my_api_settings

And that's all that you need! Only two YAML files generate a fully working configuration page with auto-generated form, validation and saving the values to the Drupal config.

Auto-generated basic Site Settings form (from the Drupal Core) with no code

The system.site schema is already defined in the Drupal Core, so we need only a single file to declare a route, connected to this schema:

file my_module.routing.yml:

my_module.basic_site_settings:
 path: '/admin/config/system/site-information-nocode'
 defaults:
   _form: 'Drupal\schema_form\SchemaConfigFromRouteForm'
   _title: 'Basic site settings'
 requirements:
   _permission: 'administer site configuration'
 options:
   editable_config_names:
     - system.site

And that's it! This route automatically generates a page /admin/config/system/site-information-nocode with the form, similar to the Drupal Core's form, written using 200+ lines of the custom PHP code.

See more detailed documentation and examples here.

Custom Config Entity forms

file config/schema/my_module.schema.yml:

my_module.my_config_entity.*:
 type: config_entity
 label: My config entity
 mapping:
   id:
     type: string
     label: ID
     description: Unique identifier for the config entity.
   myString:
     type: string
     label: My String
     description: A string value.
   myNumber:
     type: integer
     label: My Number
     description: An integer value.

See more detailed documentation and examples here.

Regular forms

You can use this module not only for configuration forms, but for any form you want! Instead of building a long PHP array for the form, you just need to describe the schema and that's it. See the examples in the separate documentation here.

Documentation

More detailed documentation and examples are published on a separate resource: Schema Form Drupal module documentation »

Similar projects

  • Automatic Configuration Form - implements the same idea, but targeted only at configuration forms. Does not use plugins, so support is limited to only built-in field types.
  • Schema Based Config Forms - targeted only at configuration forms, extendable by plugins and provides more field types out of the box.

Alternatives, based on content entities »

If you use those modules, you can simply replace them with this module Schema Form without any change in your created schemas, because it supports form declaration formats from these modules too.

Activity

Total releases
5
First release
Apr 2025
Latest release
3 months ago
Releases (12 mo)
2 ▼ from 3
Maintenance
Active

Release Timeline

Releases

Version Type Release date
1.0.0-alpha4 Pre-release Mar 23, 2026
1.0.0-alpha3 Pre-release Aug 16, 2025
1.0.0-alpha2 Pre-release May 12, 2025
1.0.0-alpha1 Pre-release May 1, 2025
1.0.x-dev Dev Apr 24, 2025