Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Schema Form

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

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
5
Tracked since
Apr 2025
Latest release
5 months ago
Releases (12 mo)
1 ▼ from 4
Maintenance
Active

Release Timeline

Releases

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