Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

So I have multiple webforms and I want to show all the forms on a single page using vertical tabs.

This is what I have so far

/**
 * Implements hook_menu().
 */
function example_contact_menu() {
  $items = array();

  $items['feedback-contact-forms'] = array(
    'title'              => 'Problem related to ..',
    'page callback'      => 'drupal_get_form',
    'page arguments'      => array('example_contact_form'),
    'access arguments'   => array('access content'),
    'type'               => MENU_CALLBACK,
  );

  return $items;
}

I have enabled the webforms as blocks to differentiate the ones which I want to show in the vertical tabs

function example_contact_webform_block_list() {
  static $blocks = array();
  if (!count($blocks)) {
    $webform_blocks = webform_block_info();
    if (count($webform_blocks) > 0) {
      foreach($webform_blocks as $key => $value) {
        $blocks[$key] = $value['info'];
      }
    }
  }
  return $blocks;
}



function example_contact_form($form_state) {
  // This gets the list of the blocks selected to display as tabs.
  // It comes from the admin interface
  $webforms = variable_get('example_contact_vertical_tabs', array());

  // List of all webform blocks required to get the block description/title
  $webforms_list = example_contact_webform_block_list();

  foreach ($webforms as $key => $webform) {

    $webform_key = str_replace('-', '_', $key);
    $webform_array_keys = explode('-', $key);
    $webform_node = node_load($webform_array_keys[2]);

    $title = str_replace('Webform: ', '', $webforms_list[$key]);
    $form[$webform_key] = array(
      '#type' => 'fieldset',
      '#title' => t($title),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
      '#group' => 'nascsp_contact',
    );

    // Can't use drupal_get_form as it returns html version of the form and I can't change the submit key 
    $webform_form = drupal_retrieve_form('webform_client_form_' . $webform_array_keys[2], $form_state, $webform_node, array(), TRUE, FALSE);


    $webform_form['actions']['webform_client_form_' . $webform_array_keys[2] . '_submit'] = $webform_form['actions']['submit'];

    unset($webform_form['actions']['submit']);

    // assign the form in the vertical tab 
    $form[$webform_key]['webform_client_form_' . $webform_array_keys[2]] = $webform_form;
  }


  // Add vertical tabs display if available.
  $form['#pre_render'][] = 'vertical_tabs_form_pre_render';

  return $form;
}

Logs are as follows enter image description here

The issue I have is webform submit buttons are not triggered. Any help will be appreciated.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.