forms – unexplained behavior (buggy?) of drupal_process_states with checkboxes in Drupal 7

I have 3 checkboxes named A, B, C. My desired behavior is as follows: if and only if, both A and B are unchecked then C becomes verified. Conversely, if A or B are checked, C becomes unchecked.

I had originally the following definition under & # 39; # States & # 39; for C:

& # 39; checked & # 39; => table (
& # 39;: contribution[name="A"]& # 39; => array (& # 39; verified & # 39; => FALSE),
& # 39;: contribution[name="B"]& # 39; => array (& # 39; verified & # 39; => FALSE),
)

It works well when both A and B start as checked on the form, so C only gets ticked when I uncheck the two A and B.

The problem is that it does not work, for example. only A starts as checked. In this scenario, uncheck A does not trigger C become verified.

I have therefore tried the following, which only works when a single A or B starts as checked – but NOT if both are checked:

& # 39; checked & # 39; => table (
& # 39;: contribution[name="A"]& # 39; => array (& # 39 ;! checked & # 39; => TRUE),
& # 39;: contribution[name="B"]& # 39; => array (& # 39 ;! checked & # 39; => TRUE),
)

Honestly, I do not even understand how this differs from my original code above (and I have not found any documentation that explains it), but I guess maybe & # 39 ;! checked & # 39; => TRUE corresponds to an element that has not been explicitly verified by the user (but its current state is unknown), while & # 39; checked & # 39; => FALSE is only something that has been explicitly unchecked. And besides, how / why & # 39; checked & # 39; => FALSE different from & # 39; snapped & # 39; => TRUEbecause it does NOT have the same effect in my tests ?!

Anyway, after trying different things, I proposed the following – which always works when only A starts as checked:

& # 39; checked & # 39; => table (
& # 39;: contribution[name="A"]& # 39; => array (& # 39; verified & # 39; => FALSE),
& # 39;: contribution[name="B"]& # 39; => array (& # 39; verified & # 39; => FALSE),
& # 39;: contribution[name="A"]& # 39; => array (& # 39 ;! checked & # 39; => TRUE),
& # 39;: contribution[name="B"]& # 39; => array (& # 39 ;! checked & # 39; => TRUE),
)

BUT – it still does not work when both A and B start as checked. In this scenario, uncheck the box A or B always triggers C become verified. And here's the big question: how can we add conditions to a AND CLAUSE TRY AN EVENT THAT IS NOT TRIGGERED BY A SUBSET OF THESE TERMS?!? In other words, if I comment on conditions 3 and 4 above, the code works when A and B Checked departure: C does not get checked until I uncheck the two A and B. But as I said above, with lines 3 and 4 added, just uncheck A OR B trigger C to be checked, which is not what I want !!

So my question is twofold: how / why does this happen with 2 of 4 conditions and, of course, how can I get the desired effect, as stated in my first paragraph?