Problem/Motivation

Evidence suggests that mankind has tried to embed forms ever since the first tribes managed to invent bureaucracy. As a species, we have been able to launch software, start-ups, people into space, and the Eurovision Song Contest, but never have we achieved that what our ancestors wished for.

Embedding forms is nothing more than using multiple objects to build parts of a larger form. The idea is that by providing abstraction between parent forms and subforms, we improve the reusability of individual components. #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms) tries to fix this for form states. Currently, there is no interface for embedded forms, other than PluginFormInterface, which can technically be reused, but it's very much part of the plugin system.

Let's make our ancestors proud!

Proposed resolution

Introduce SubformInterface, which uses SubformStateInteface as introduced by #2537732-69: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms).

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Xano created an issue. See original summary.

Xano’s picture

This is functionally equivalent to PluginFormInterface, which, as mentioned in the issue summary, is technically what we want, but without the $form parameter to ::buildSubform(), because the subform's render array does not exist at that time, and the parent form should not make assumptions about the subform's structure and vice versa. Such dependencies belong in interfaces.

Xano’s picture

Title: Introduce SubFormInterface » Introduce SubformInterface
Issue summary: View changes
Issue tags: +Subforms
fago’s picture

yes, a proper solution to the old subform problem would help in many different cases. I remember there were some issue suggesting to care for embedded or embeddable forms. Actually, I must say I'd prefer the EmbeddedFormInterface terminology as it's more precise than "subform". The meaning of "subform" might not be so obvious.

+ * Because this is an embedded form, it is not responsible for handling a
Looks like the patch partly uses the embedded-terminology already, so let's better switch to that terminology completely.

Xano’s picture

I'm not in favor of any particular name, as long as it's consistent with whatever name we choose in #2537732: PluginFormInterface must have access to the complete $form_state (introduce SubFormState for embedded forms).

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Xano’s picture

borisson_’s picture

FileSize
378 bytes
1.4 KB

Ran this trough coder, attached patch fixes it's remarks.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

EclipseGc’s picture

Status: Needs review » Closed (won't fix)

SubformStateInterface landed in core long ago and solved most of the technical problems associated with this. Closing.

Eclipse