I created a a custom webform and noticed that when I submitted it on the node page, it did not redirect to node/%nid/webform/components like the webform content type that ships with the module does.
So I started digging and found this in webform.module:
/**
* Implements hook_form_alter().
*/
function webform_form_alter(&$form, $form_state, $form_id) {
$matches = array();
if (isset($form['#node']->type) && $form_id == $form['#node']->type . '_node_form' && in_array($form['#node']->type, webform_variable_get('webform_node_types'))) {
$node = $form['#node'];
// Preserve all Webform options currently set on the node.
$form['webform'] = array(
'#type' => 'value',
'#value' => $node->webform,
);
// If a new node, redirect the user to the components form after save.
if (empty($node->nid) && in_array($node->type, webform_variable_get('webform_node_types_primary'))) {
$form['actions']['submit']['#submit'][] = 'webform_form_submit';
}
}
}
The real issue is this conditional:
in_array($node->type, webform_variable_get('webform_node_types_primary'))
I looked in the database, and there's no entry in the variables table for webform_node_types_primary. So I dug further and found that it defaults to just 'webform'. There is no place in the code that does a variable_set for this value, so the value will always be just 'webform'.
Is this by design, or should this conditional instead be using webform_variable_get('webform_node_types'), so that it will perform this redirect for any type of webform content that the user has set up?
Comments
Comment #1
rukaya commentedThis is an issue for 6.x-3.20 as well. I changed webform_node_types_primary to webform_node_types as molenick suggested.
Comment #2
danchadwick commentedThe -3.x branches receive only critical bug fixes. Changing this to 7.x-4.x to see if the bug has been fixed there.
Comment #3
danchadwick commentedI looked into this. This is intentional behavior. The assumption is that only the 'webform' node type has this behavior. You can modify this by setting it in settings.php to an array of content type machine keys that should be considered primary.