Hey, I have a question on using vertical_tabs with hook_form_alter. I'm using this in combination with the formblock module and have a situation where two node creation forms exist: one on node/add/NODETYPE and one through a block that exists on all other pages. Here's what I have:

function mymod_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'NODETYPE_node_form':
    // Get the path
    $path = drupal_lookup_path('source', $_GET['q']);
    if($path == false){
      $path = $_GET['q'];
    }
    if($path == 'node/add/NODETYPE') {     
      // Enable vertical tabs on a form if displayed through node/add/NODETYPE
      $vtabs = variable_get('vertical_tabs_forms', array());
      $vtabs['NODETYPE_node_form'] = TRUE;     
      variable_set('vertical_tabs_forms', $vtabs);
    }
    else {     
      // Disable vertical tabs on a form if displayed through formblock module
      $vtabs = variable_get('vertical_tabs_forms', array());
      $vtabs['NODETYPE_node_form'] = FALSE;     
      variable_set('vertical_tabs_forms', $vtabs);
    }
    break; 	 
  }  
}

The issue I'm having is that if I go from node/add/NODETYPE to a page that has the block, the block still displays vertical tabs. However, if I refresh the page, the vertical tabs disappear. Any ideas? Is there a way to implement this through settings.php? I tried adjusting module weights but this didn't work.

Comments

rj’s picture

bump. any insight/guidance/suggestions would be appreciated, thanks.