I have a dependent A that toggles visibility of dependent B when it has a specific value. If A has 'value 1' then B is shown. If B has 'value 2' then C is shown. C is not hidden when A has a value other than 'value 1'. I have hide dependent if dependee is not visible checked. This is not taking effect.

First set up for conditions was:

field_summary_0_1 field_block_selection_1
field_summary_0_1 is visible when field_block_selection_1 has value "block_1".
AND
field_summary_0_1 field_selections_0
field_summary_0_1 is visible when field_selections_0 has value "track 1".

I also tried adding an invisible condition:

AND
field_summary_0_1 field_block_selection_1
field_summary_0_1 is invisible when field_block_selection_1 has none of the values: block_1.

Another condition makes field_selections_0 only visible when field_block_selection has the value "block_1".

Apparently field conditions is not applying bitwise AND with the states. How can I set these fields up so that field_summary_0_1 is no longer visible when field_block_selection_1 doesn't have the value "block_1"?

Comments

arosboro’s picture

Title: AND grouping does not hide dependent when dependee A is 0 and dependee B is 1 » AND grouping does not hide dependee when dependent A is 0 and dependent B is 1

I also tried the following which did not work:

field_summary_0_1 field_block_selection_1
field_summary_0_1 is invisible when field_block_selection_1 has none of the values: block_1.
XOR
field_summary_0_1 field_selections_0
field_summary_0_1 is visible when field_selections_0 has value "track 1".

1 xor 1 should evaluate to 0, but it's coming up as visible. It seems like the javascript states don't respect grouping.

I did some digging in the code and found: I did some snooping in the code and found:

[code]


conditional_fields_evaluate_groupings($groups) {
  $or = $and = $xor = TRUE;
  if (!empty($groups['OR'])) {
    $or = in_array(TRUE, $groups['OR']);
  }
  if (!empty($groups['AND'])) {
    $and = !in_array(FALSE, $groups['AND']);  // The two
  }
  if (!empty($groups['XOR'])) {
    $xor = array_sum($groups['XOR']) == 1;
  }
  return $or && $and && $xor;
}

[/code]

It was called after form validation though, I'm not sure it's used for the javascript states handler. The logic there makes sense though, and it should work.

arosboro’s picture

Title: AND grouping does not hide dependee when dependent A is 0 and dependent B is 1 » AND grouping does not hide dependent when dependee A is 0 and dependee B is 1
arosboro’s picture

Title: AND grouping does not hide dependee when dependent A is 0 and dependent B is 1 » AND grouping does not hide dependent when dependee A is 0 and dependee B is 1
Status: Active » Closed (works as designed)

I didn't check in the lastest 3.x dev branch on git, so I didn't realize that this actually works as designed.

arosboro’s picture

Issue summary: View changes

Updated issue summary.