WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

Combining two forms in Drupal

Submitted by barnettech on Thu, 10/08/2020 - 14:45
 // Build and render the group_content/user profile form for this user.
  $group_content = \Drupal::entityTypeManager()
    ->getStorage('group_content')
    ->loadUserGroupContentByUser($user);
  $inline_form = \Drupal::service('plugin.manager.commerce_inline_form')
    ->createInstance('content_entity', [], $group_content);

  $form['group_content'] = $inline_form->buildInlineForm(
    [
      '#parents' => array_merge($form['#parents'], ['group_content']),
      '#inline_form' => $inline_form,
      '#weight' => 10,
    ],
    $form_state
  );