I configured a webform to show a Name field only when a certain checkbox is empty (if [checkbox field] is empty then [name field] is shown).

I hide other fields in the same manner, dependent on the same checkbox, and they all toggle correctly, but the Name field remains visible no matter what.

I'm using the 7.x-1.x-dev from 2015-May-07.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Webbeh’s picture

Able to reproduce this issue as well. Conditionals just don't seem to be sticking to the Name field.

nathan573’s picture

Encountered an issue I think is related to this. I'm using conditional fields in a webform, but not on the actual Name Field. Whenever the field produced by the the Name Field module is updated it throws an error, though:

Error: TypeError: $triggerElement.attr(...) is undefined
Source File: http://localhost/sites/all/modules/webform/js/webform.js?nu0jqg
Line: 116

I tracked it down to this function:

  /**
   * Event handler to respond to field changes in a form.
   *
   * This event is bound to the entire form, not individual fields.
   */
  Drupal.webform.conditionalCheck = function (e) {
    var $triggerElement = $(e.target).closest('.webform-component');
    var $form = $triggerElement.closest('form');
    var triggerElementKey = $triggerElement.attr('class').match(/webform-component--[^ ]+/)[0];
    var settings = e.data.settings;
    if (settings.sourceMap[triggerElementKey]) {
      Drupal.webform.doConditions($form, settings);
    }
  };

So, I think our issues are caused by the Name Field module not rendering divs with the structure and classes that the Webform module is looking for. The above JS seems to break because the top level "form-item" div that contains the Name fields does not have a "webform-component" class. I looked at the Name Field module code but could not immediately identify a place that I might be able to add that class. Hopes this helps someone.

  • Alan D. committed b8fbd6b on 7.x-1.x
    Issue #2496775 by Alan D.: Missing webform theme wrapper on render: Name...
Alan D.’s picture

Title: Webform component not working with conditionals » Missing webform theme wrapper on render: Name component not working with Webform conditionals.
Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Active » Patch (to be ported)
FileSize
543 bytes

Super easy fix pushed (missing element theme wrapper).

Need to assess D8 if relevant still.

Alan D.’s picture

Status: Patch (to be ported) » Fixed
Related issues: +#2953851: Name field integration with Webform module

Closing, need to fully port everything related to webform integration

Status: Fixed » Closed (fixed)

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