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

boromino created an issue. See original summary.

boromino’s picture

boromino’s picture

Status: Active » Needs review
svetoslav.dragoev’s picture

I 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.

abarrio’s picture

Patch from #4 has worked perfect for me.
Thanks!

saurabh-2k17’s picture

Hey, 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?

saurabh-2k17’s picture

So 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.

saurabh-2k17’s picture

Status: Needs review » Reviewed & tested by the community
saurabh-2k17’s picture

Assigned: Unassigned » saurabh-2k17
Status: Reviewed & tested by the community » Needs work

I 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.

saurabh-2k17’s picture

Assigned: saurabh-2k17 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new720 bytes
szhu’s picture

Status: Needs review » Reviewed & tested by the community

  • boromino authored e8ee8e6a on 4.x
    Issue #3109227 by saurabh-2k17, boromino, svetoslav.dragoev: Conditional...
saurabh-2k17’s picture

Status: Reviewed & tested by the community » Fixed

Thank you everyone for your effors.

Status: Fixed » Closed (fixed)

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