I've found more than once that when I'm building a custom form, I would like to re-use a form element, that is actually a field widget. When trying to re-use something like the Openlayers widget for input of coordinates, or Hierachical select for a nice looking way of picking terms, this is definitely not trivial.

There is no way at all actually, unless one creates a dummy content type, an instance of that type, and the uses field_attach to create the form.

officially though,

Widgets are Form API elements with additional processing capabilities.

. Based on that, I'm wondering if it would be possible to introduce something like a 'base element' => 'form_id', into the widget definition, allowing an easy way for/encouraging a module to specify it's element separately from it's widget.

How does this sound? :)

Comments

apaderno’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Since now widgets are objects of PHP classes, there is no need to have such a property: You just sub-class a class to implement your widget.