Hi,
Problem/Motivation
Like many people (#1597988: Simplify reusing forms between widget's and elements) when I am building a custom form I would like to use a form element that is actually just a field widget: Image or Link fields for instance.
For example if we want to add a link element to a custom form, we have to redevelop what the Link widget already do (it creates duplicated code, maybe some security issues etc..).
Proposed resolution
A good thing could be to take example of what the Address module do.
It defined a form element address
and use it on the widget.
So rather than to "hardcode" the "form element" in the widget, it could be interesting to define a real form element. Thanks to that we have reusable code.
It could be a good practice to follow for contrib module.
Remaining tasks
- Defined which fields needs to expose a form element
- Create a patch
User interface changes
None
API changes
None.
Data model changes
None.
If you find this interesting, I'll be glad to work on it with some help.
Comments
Comment #3
beram CreditAttribution: beram as a volunteer and at Smile commentedA sandbox module has been started for the moment: https://www.drupal.org/sandbox/beram/2915340
It starts with a quick implementation of a link form element as I needed it.