Skip to content

What contrib sees

Human reviewed 2026-11-30

Nothing changes for a contributed module until it, or the module whose data it uses, chooses to adopt. No API is removed or deprecated, stored config does not change, and form alters keep working on every hand-written form.

Only the new way in is strict. Config::save(), a config action and a hand-written form behave as they do today. A config object gets no new way in until its owner declares an operation and names the permission it asks.

At each rung

The rungs are the steps of the adoption ladder. A module climbs them at its own pace, and each works without the next.

"Owner" is the module whose data it is. "Another module" reads, writes or extends it.

Owner's rung The owner Another module
0. Nothing No change. No change.
1. A resource beside the form(s) Adds a resource class. Its forms, routes and config schema stay. Nothing has to change. Its hook_form_alter() still runs. If it adds settings or checks, it should add an alter of the resource as well, so they reach every other way in (below). It may also call the operation.
2. An explicit structure Declares a plugin's settings in Portable Schema. Nothing has to change. If it has plugins of its own, it is encouraged to declare their settings in Portable Schema too, or to fill in their config schema: labels and constraints there are read until it does.
3. The generated form(s) Points each form's route at the operation's form. The form has a new form id and element tree, so a hook_form_alter() on it has to move. A module that added its alter at rung 1 deletes its form alter instead, or keeps only what is cosmetic.
4. Old code removed Deletes the hand-written form classes, often whole. Nothing beyond rung 3.

Adding an alter at rung 1

A form alter changes one form. Once the owner has a resource, a Tool API tool, an HTTP call or Drush runs the operation without that form. A setting the form alter adds cannot be sent there and is missing from the contract, and a check it adds does not run. Values already stored are kept.

An alter of the resource adds the same setting to the contract.

Form alter hook_form_alter() Alter of the resource alterInputs() Owner's form hand-written at rung 1 Tool API tool its input schema HTTP endpoint its OpenAPI document Drush the input it accepts from rung 3
A form alter reaches one form. An alter of the resource reaches every other way in, and the form too once it is generated (dashed).

The two examples below come from surface_examples_extras, an example module in the proof of concept. It stands in for a contributed module that adds settings to core's content types: here, a list of audience tags, which says who content of that type is written for. It adds them both ways, so the two can be compared.

Example, today: altering the content type form

This is what a contributed module does now. It alters core's content type form, node_type_form, and that form is the only place that offers the setting and checks it:

  #[Hook('form_node_type_form_alter')]
  public function formNodeTypeFormAlter(array &$form, FormStateInterface $form_state): void {

    // Loading the content type and its stored tags is left out.

    $form[self::ELEMENT] = [
      '#type' => 'details',
      '#title' => $this->t('Editorial review'),
      '#group' => 'additional_settings',
      '#tree' => TRUE,

      // A second setting is left out.

      NodeTypeReviewSettings::TAGS => [
        '#type' => 'textfield',
        '#title' => $this->t('Audience tags'),
        '#description' => $this->t('Who content of this type is written for, separated by commas, for example "Local news, Sports".'),
        '#default_value' => is_array($tags) ? implode(', ', $tags) : '',
        '#maxlength' => 1024,
        '#element_validate' => [static::class . ':validateAudienceTags'],
      ],
    ];
    $form['#entity_builders'][] = static::class . ':buildNodeType';
  }

Its element validator splits the text on commas, lower cases each tag and checks it. Only this form runs it. None of this has to change at rung 1.

Example, the ask: adding it to the contract

This is what it would add once content types have a resource. Core has none today, so the proof of concept supplies one, NodeTypeResource, in a second example module, surface_examples_node_type. In core, that resource would be the node module's.

The ask is one class. #[Alters] names the resource it adds to, and alterInputs() declares the setting: its type, its label and the check each tag has to pass. NodeTypeReviewSettings is the example module's own class of setting names:

#[Alters(NodeTypeResource::class)]
final class NodeTypeAlter implements AltersInputsInterface, AltersStoredAsInterface {

  // The constructor is left out.

  public function alterInputs(BlueprintAdditionsInterface $inputs): void {

    // A second setting is left out.

    $inputs->add(NodeTypeReviewSettings::TAGS, Schema::list(Schema::string()
      ->title($this->t('Audience tag'))
      ->pattern(NodeTypeReviewSettings::TAG_PATTERN)
      ->message('pattern', $this->t('An audience tag is lower case letters and digits, words joined by one space or one hyphen, with nothing around it.')))
      ->title($this->t('Audience tags'))
      ->description($this->t('Who content of this type is written for, each tag listed once and in lower case, for example "local news" or "sports".'))
      ->default([])
      ->uniqueItems(TRUE)
      ->annotation('x-surface-settings', [CommaSeparatedListWidget::SETTING => TRUE]));
  }

With that class, the setting is part of the content type operations wherever they run: the Tool API tool, the HTTP endpoint and its OpenAPI description, and Drush. A caller sends a list of tags, and a tag that fails the check is refused. The setting is stored where the form alter already stores it, under third_party_settings.<module>. Config entities such as content types have that place today, and simple config would get it (Structures). An alter can add keys and narrow the owner's rules, and cannot loosen them.

Until the owner reaches rung 3 the module keeps both, the form alter and the class, and the setting is described twice. A module whose form alter is only cosmetic needs no alter.

When a form alter has to move

Rung 3 is optional, and its cost arrives one owner at a time. Core's policy allows form arrays to change in a minor release (frontend backward compatibility), and core would move its own forms one at a time.

Settings and checks move to an alter of the resource, as above. The generated form draws them with the owner's keys, so the form alter for them can go. Form alters can still change how the generated form looks, such as its markup, or add a message or a redirect.

A module that copies another module's definitions

A module that writes its own copy of another module's data definitions, for Tool API tools or ECA, can read the operation's contract instead and delete the copy. Example 3 shows this for fields: Tool Belt, a contributed module of Tool API tools, reads a field's settings from config schema, and a declared structure gives it more to read. Nothing makes it do so.