Allow Form Decorators

Created on 17 February 2024, 4 months ago

Problem/Motivation

Drupal provides several methods for altering forms, with the hook_form_alter being one of the most widely used. This approach allows for the modification of the form array and the addition of static callbacks for validation and submission processes.

Despite its flexibility and ease of use, this method falls short of integrating with the concept of altering the implementing class for a specific feature, as is possible with services.

Proposed resolution

Allow form decorators.

On https://www.drupal.org/project/form_decorator β†’ there is a Proof of Concept how one could offer an easy way to decorate forms.

Key benefits might be:

  1. Dependency Injection in your form logic
  2. Easily reuse methods of the original class
  3. No need for custom callbacks - one can add logic to submit/validation handlers
  4. Having the form logic in one separate file instead of .module
✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component
FormΒ  β†’

Last updated about 5 hours ago

Created by

πŸ‡©πŸ‡ͺGermany Harlor Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024