Allow form service wiring via constructor parameter attributes

Created on 1 November 2023, over 1 year ago
Updated 2 November 2023, over 1 year ago

Problem/Motivation

To wire services to a form, developers must implement a custom create() method that pulls services from the container and calls the constructor.

Using PHP 8 attributes, we can tag constructor parameters directly and allow the base class to discover and inject the required services, dropping the create() method entirely.

In 📌 Allow controller service wiring via constructor parameter attributes Fixed we added an AutowireTrait and applied it to ControllerBase for controllers. We can apply the same trait to FormBase for all forms to use.

Steps to reproduce

Proposed resolution

Add AutowireTrait to FormBase.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component
Form 

Last updated 23 minutes ago

Created by

🇬🇧United Kingdom longwave UK

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

Comments & Activities

Production build 0.71.5 2024