Posted by plach on August 14, 2012 at 1:28am
20 followers
Jump to:
| Project: | Drupal core |
| Version: | 8.x-dev |
| Component: | entity system |
| Category: | task |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
| Issue tags: | D7 Form API challenge, Entity forms |
Issue Summary
Spin-off from #1499596: Introduce a basic entity form controller: we need to be able to reuse the form generated by an entity form controller and ensure it can be embedded into another form.
To be completed.
Comments
#1
and we need to make sure that we can embed multiple forms at the same time!
#2
This partially duplicates a couple of other issues:
#367006: [meta] Field attach API integration for entity forms is ungrokable
#766146: Support multiple forms with same $form_id on the same page
(...and more...)
#3
I'm interpreting this issue as wanting to put the $form returned by EntityFormControllerInterface::build() into some other $form such that the HTML output is a single
<form>tag. Is that correct, or is this about wanting multiple $form arrays sharing the same $form_id (e.g., several entities of the same type) to be each rendered as their own<form>tags, but to not have id / form processing collisions when all rendered on the same page?#4
fwiw, I'm interpreting this as meaning that I could put any (or many) entity forms into the same form and determine what sort of entity forms existed within this and hand off processing of that separately. Something like:
<?php
$form = array();
$node = entity_create('node', array(
'uid' => $user->uid,
'type' => 'page',
'langcode' => node_type_get_default_langcode('page'),
));
$form['node'] = entity_get_form($node);
$form['something_else'] = array(
'#type' => 'select',
'#options' => ...
);
?>
And then be able to iteratively pass the form state to entity_form_submit and have it process the various entity forms embedded in the greater form. Is this a correct interpretation?
Eclipse
#5
I think @fago's plan is to support both scenarios in #3.
@fago:
Is this correct?
@EclipseGC:
I think your example is not correct because
entity_get_form()returns an already processed form ready to be rendered. As pointed out in #3 the correct way should be using the value returned byEntityFormControllerInterface::build().#6
I was thinking of what is described in #4. Avoinding form id collisions is something different we might want to fix generally elsewhere.