Just had the need to implement form with conditions (from Condition Plugins) for two different module settings pages.
I think needing conditions for settings forms and entity forms isn't a very rare case and most of us have seen them already (or someone implementing the conditions by hand, as they weren't aware it exists or how to use them - indeed it's not easy to find documentation but that's another topic).
Typical forms where such conditions are useful:
Looking for existing implementations of form using conditions, I found
https://git.drupalcode.org/project/core_extend/-/blob/8.x-1.x/src/Form/C...
in the old
https://www.drupal.org/project/core_extend →
module.
And I think that's an excellent basic idea for core to unify and simplify use of conditions in forms.
So the question is, if a trait is the best way to provide an easier integration (I think so) or if a form element would even make sense. Thinking about that, I think a form element would be hard to configure, harder to individualize and as conditions are typically displayed as vertical tabs, I think a form element would be untypical.
Implement a Condition Plugin form in core or contrib
Add a ConditionsFormTrait or a "conditions" form element to core
Discuss
Implement
Release
None
Active
11.0 🔥
plugin system