- π¦πΊAustralia sime Melbourne
You might find yourself wandering around in circles so you should read https://www.drupal.org/node/1464758#comment-13949961 β
The version that went in with #557272: FAPI: JavaScript States system β unfortunately was a bit premature and didnβt include support for OR: it was only possible to write AND conditions. This patch fixes this behavior while maintaining full backwards compatibility (all valid existing states descriptions work in exactly the same way with this patch).
Instead of just ANDing all conditions together, this patch makes states.js aware of arrays. All elements in an object literal ({ ... }
) are ANDed (like now) and all elements in a array literal ([ ... ]
) are ORed. This allows you to write conditions like:
"enabled": [ {"select[name=\"date_default_timezone\"]": { "value": "America/Winnipeg" }}, {"select[name=\"date_first_day\"]": [{ "value": "2" },{ "value": "3" }]} ]
In PHP, this would be:
array(
"enabled" => array(
array("select[name=\"date_default_timezone\"]" => array("value" => "America/Vancouver" )),
array("select[name=\"date_first_day\"]" => array(array("value" => "2"), array("value" => "3"))),
)
)
Note that itβs possible to use the array notation (without =>
, thus with numeric indexes in PHP) both around selectors and within selectors. In the above example, the element is enabled when either the default timezone is Vancouver or when the user selects Tuesday or Wednesday as week start days (full sample code attached).
The XOR operator is supported as well: when writing an OR statement, you can insert the string 'xor'
at any position to make the OR exclusive:
array(
"enabled" => array('xor',
array("select[name=\"date_default_timezone\"]" => array("value" => "America/Vancouver" )),
array("select[name=\"date_first_day\"]" => array(array("value" => "2"), array("value" => "3"))),
)
)
is possible, but
array(
"enabled" => array(
array("select[name=\"date_default_timezone\"]" => array("value" => "America/Vancouver" )),
'xor',
array("select[name=\"date_first_day\"]" => array(array("value" => "2"), array("value" => "3"))),
)
)
works just as well.
Fixed
7.0 β°οΈ
Last updated
Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.
It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.
After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
You might find yourself wandering around in circles so you should read https://www.drupal.org/node/1464758#comment-13949961 β