If the visible state of a (select) field 1 depends on another select field 2 that can have multiple values, field 1 remains hidden when you open the node edit form, although field 2 has values selected from the set of values (field 1 however shows if you then change the value(s) of field 2).
The patch from https://www.drupal.org/project/drupal/issues/1149078 fixes a related issue in Drupal core (The States API won't currently pick up the value of a select field with #multiple = TRUE option.), but the #state syntax of the conditional module select handler has to be adapted accordingly.
Field 1 condtion configuration:
conditional_fields:
<uuid>:
dependee: field_xyz
settings:
state: visible
condition: value
grouping: OR
values_set: 3
value: ''
values: "2\r\n8"
value_form: { }
effect: show
effect_options: { }
selector: ''
entity_type: node
bundle: xyz
type: options_select
region: content
Field 2 configuration:
field_xyz:
weight: 3
settings: { }
third_party_settings: { }
type: options_select
region: content
Comments
Comment #2
boromino commentedComment #3
boromino commentedComment #4
svetoslav.dragoev commentedI am applying an update of the proposed patch, it works perfect when we have the #multiple = true option set for the field on which condition depends, but strips and breaks the logic for single field with selected "Any of these values (OR)". I've just covered both cases, leaving the old intact way and having the updated for array value when field is multiple.
Comment #5
abarrioPatch from #4 has worked perfect for me.
Thanks!
Comment #6
saurabh-2k17 commentedHey, I am using 4.0.0-alpha2, I applied the Drupal core patch along with these two one by one, but sadly it is not working in my case.
@abarrio what version did you use when you last applied this patch?
Any ideas why this is not working?
Comment #7
saurabh-2k17 commentedSo the actual issue is with the Drupal core, no changes required in the above patch as it works fine. Not every patch is going to work from here - https://www.drupal.org/project/drupal/issues/1149078, in my case #142 worked.
Comment #8
saurabh-2k17 commentedComment #9
saurabh-2k17 commentedI noticed that the patch is not applying on 4.x branch, moving this to need work. I will create a new patch compatible with that branch and will commit that.
Comment #10
saurabh-2k17 commentedComment #11
szhu commentedComment #13
saurabh-2k17 commentedThank you everyone for your effors.