I have a
Subscription custom entity and I would like to use the default entity form for administration tasks and a custom multistep form for the subscription process.
I added an address field to my
Subscription entity and I would like to use the widget in one of the custom form steps.
I was expecting I could use something like
'#type' => 'widget_id' plus some widget configuration, but it does not seem to be so simple as this answer points out.
a widget and a form element are two different things that are used in different cases; consider a widget a more specialized type of form element.
What would be the right approach then? In the
field_attach_form change record a comment suggests
$display = EntityFormDisplay::collectRenderDisplay($entity, 'default'); $display->buildForm($entity, $form, $form_state);
How do I get just my address field? Form display modes?
And then, how do I deal with validating and storing the data properly?