FormAlter as Plugin
This module allows developers to use object-oriented plugins to alter Drupal forms, paragraph forms, and inline entity forms. It supports dependency injection and allows plugins to be applied in a specific order. The module also enhances the Web Profiler module by showing which plugins have affected each form.
Obsoletion
Drupal 11.2+ now supports OOP hooks. You should move your FormAlter plugins into the /src/Hook/ folder and convert them to #[Hook()] attributes:
- https://www.drupal.org/blog/drupal-11-2-0
- https://www.hashbangcode.com/article/drupal-11-object-oriented-hooks-and-hook-service-classes
There are no plans to upgrade this module to Drupal 12 as a result, as traditional hooks are deprecated.
Overview
This module provides three annotation Plugins to be used to alter Forms, Paragraphs forms and Inline Entity Forms.
It allows you to use Dependency Injection of services and to define a weight for your plugin which will affect the alteration queue.
Multiple plugins can alter the same form.
It also decorates the Forms data collector used by the WebProfiler module by adding a list of all the plugins affecting each form.