Is there a way to dynamically switch between multipage and horizontal tabs? My customer wants to new user forms to be multipage, but existing user profiles to be horizontal tabs.

Comments

NancyDru created an issue.

NancyDru’s picture

It looks like part of the problem is that user_register_form() and user_profile_form() both use user_account_form() which Field_Group has taken over.

NancyDru’s picture

What I did:

function mymodule_form_alter(&$form, &$form_state, $form_id) {
  switch ($form_id) {
    // Create a new account form.
    case 'user_register_form':
      // We sort of need to cheat.
      // We will override the multitab settings to become multipage.
      foreach ($form['#groups'] as $group_name => $stuff) {
        if ($group_name == 'group_tabs') {
          $form['#fieldgroups']['group_tabs']->format_type = 'multipage-group';
          $form['#fieldgroups']['group_tabs']->format_settings = array(
            'formatter' => '',
            'instance_settings' => array(
              'classes' => '',
              'page_header' => 1,
              'move_additional' => 1,
              'page_counter' => 1,
              'move_button' => 1,
              ),
            );
        }
        else {
          $groups[$group_name] = $stuff->label;
          $form['#fieldgroups'][$group_name]->format_type = 'multipage';
          $form['#fieldgroups'][$group_name]->format_settings = array(
            'formatter' => 'no-start',
            'instance_settings' => array(
              'description' => '',
              'classes' => '',
              'required_fields' => 1,
              ),
            );
        }
      }
      break;