I am trying to include a user registration form within a Commerce pane form. I am currently using (within buildPaneForm):

$user_form = $this->entityFormBuilder->getForm(user_load_by_mail($this->currentUser->getEmail()), 'guest_checkout_profile');
$pane_form['user_form'] = $user_form;
$pane_form['user_form']['#tree'] = TRUE;

The user form simply isn't shown though. I can add a test field that will show:

$pane_form['test'] = ['#type' => 'textfield', '#title' => 'test'];

$user_form has the correct form array, with the appropriate fields from the guest_checkout_profile form display mode.

I was pointed to IPE's embedding a form within another form, but I don't see how what I'm doing is different there (from a "get the form to show" standpoint - validation and submission I'll deal with if I get there :D).

Baby steps - how can I get the form to even be rendered?

  • You can't have a complete form within a form , neither HTML nor Drupal supports that. What you are referencing is not a full form, it's a configuration form for a plugin which is just a part of a form, kind of like a field widget. Have a look at inline entity form/paragraphs widgets for examples on how to use the entity form display to build the form elements and then process them again from a custom submit callback. – Berdir Jul 19 '17 at 22:27
  • drupal.org/node/2774077 – user21641 Jul 20 '17 at 3:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.