Hi everyone, we love the conditional field module and want to share a bugfix.

In function \conditional_fields_form_after_build() fields which have a different option than "value" are not beeing evaluated.

See Line 508 in sites/all/modules/conditional_fields/conditional_fields.module:
// Conditions different than "value" are always evaluated against TRUE.

But if you mix none value and value dependencies for one field it gets evaluated in conditional_fields_dependent_validate(). (See Attachment Auswahl_814.png)

When the dependent is evaluated in conditional_fields_dependent_validate() the function checks if its beeing triggered by calling conditional_fields_evaluate_dependencies(). Sadly conditional_fields_dependent_validate() also evalutes the non value dependencys which of course fails.

Ive modified the following code that dependencies with mixed value and none value are considered correctly as triggered.

// Conditions different than "value" are always evaluated against TRUE.
    if($dependency['options']['condition'] !== "value"){
      $evaluated_dependees[$dependent['#field_name']][$dependency['options']['grouping']][] = TRUE;
    }else {
      $evaluated_dependees[$dependent['#field_name']][$dependency['options']['grouping']][] = conditional_fields_evaluate_dependency('edit', $values, $dependency['options']);
    }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

iTiZZiMO’s picture

Title: conditional_fields_evaluate_dependencies » conditional_fields_evaluate_dependencies fails evaluating triggered value from none value dependencys
FileSize
1.28 KB
iTiZZiMO’s picture

Status: Active » Needs review
iTiZZiMO’s picture

iTiZZiMO’s picture

  • peterpoe committed a635f29 on 7.x-3.x
    Issue #2467361 by iTiZZiMO, peterpoe:...
peterpoe’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

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