I noticed strange behavior with my add to cart forms on product pages when using their select lists for sizes. Drupal core ajax uses the form submit button's id in some auto incrementing manner that is dependent on the id being present. The webform module is breaking that Drupal core ajax functionality by removing the id from the submit button.

webform.module

// Add process functions to remove the IDs forced upon buttons and wrappers.
$actions_pre_render = array_merge(element_info_property('actions', '#pre_render', array()),
  array('webform_pre_render_remove_id'));
$buttons_pre_render = array_merge(element_info_property('submit', '#pre_render', array()),
  array('webform_pre_render_remove_id'));
function webform_pre_render_remove_id($element) {
  if (empty($element['#states'])) {
    $element['#id'] = NULL;
    // Removing array parents is required to prevent theme_container from adding
    // an empty ID attribute.
    $element['#array_parents'] = NULL;
  }
  return $element;
}

I resolved this by applying a form alter to my webform.

function exact_target_webform_form_webform_client_form_21_alter(&$form, &$form_state) {
   $form['actions']['submit']['#pre_render'] = null;
}

By removing your prerender, everything began to function normally again.

I poked around the webform module and I couldn't see anything that needed the id removed. I am not sure why this was necessary but my webform continued to function normally after the change.

I strongly encourage you to respect not only Drupal core functionality but the other people posting issues here as well. Particularly those posting about ajax issues possibly occurring due to the way core behavior is being overwritten by this module rather than their custom code.

Comments

dpalmer’s picture

Issue summary: View changes
dpalmer’s picture

Issue summary: View changes
dpalmer’s picture

Issue summary: View changes
dpalmer’s picture

Issue summary: View changes
dpalmer’s picture

Issue summary: View changes
dpalmer’s picture

Issue summary: View changes
dpalmer’s picture

Issue summary: View changes
dpalmer’s picture

Issue summary: View changes
DanChadwick’s picture

Category: Bug report » Support request
Priority: Critical » Normal
Status: Active » Fixed

The form ids are removed because webforms may be present on the page in more than one place. This creates duplicate ids which is invalid HTML. Webform has worked this way for a long time -- predating my involvement as maintainer. Luckily you have found a work around for your needs.

I haven't done this, but you can use git to search the repository for when these lines when in and find the relevant issues. I'm sure there is more background there.

I strongly encourage you to respect not only Drupal core functionality but the other people posting issues here as well.

I see from the revision history that you have toned down your initial negative comments about me and how I handle the issue queue. I would ask that you reflect on why I might donate so much time (and therefore money) to solving other people's problems and implementing features that do not benefit me personally. When you figure it out, tell me because right now I have no idea.

EDIT: Please read the Priority Guidelines in the Issue Queue Handbook. This is not a Critical issue. Not even close.

dpalmer’s picture

Why would the same webform need to be on the same page twice? I think there's a better way to solve that rare occurrence (webform exposed as a block and viewing the webform node) than to override core functionality.

As far as the whole time and money thing goes...Do you use views? Do you use migrate? Do you use any other modules on drupal.org? Do you use Drupal? Do you donate money to those maintainers? I didn't think so. Your module is the only one I've seen that asks for funding on the project page. Webform is a very popular module and the recognition you get as being the maintainer should be more than enough but apparently it's not. That's why I took such a negative tone.

DanChadwick’s picture

Why would the same webform need to be on the same page twice?

Feel free to research the issue yourself. That's what I would do.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.