I have a node type with a Boolean field that only a user with an admin profile can set (Field Permissions Module's behavior) and a text field that can be shown in edit form only if the boolean field is true (Conditional Field behavior).

When I am logged in as admin, all work great: If check the boolean field, text field shows up and hide when I uncheck boolean field. Now as administrator I uncheck the boolean field and save the node.

Then as an other user having another role (who has edition rights on my test node of course), I edit the node. I can't have access to the boolean field with this role, but the boolean was set to false when I saved it as admin.

Comments

kthull’s picture

I was struggling with the same issue and I've narrowed it down to the fact that if the role does not have permissions to edit the field, then the dependencies are not evaluated. In my use case, I'm setting visibility of fields based on a workflow state field that the editing roles can view but not edit, so things are failing.

Oddly enough, it looks like this issue for the D6 version Conditional logic should not be added if the user does not have access to the control field is the opposite of what I need.

I think I can get around this via css since I'm not using the admin theme for node edit forms for editor roles, but I think the logic should still apply regardless of whether a role can edit the field.

kthull’s picture

So in the end, I went with a hybrid solution. For admins, conditional fields is controlling the dependency, and the dependee is not required. Then I wrote a custom form alter module that loads the user and the node so that I can expose/hide the radio button field and set/unset as required for various roles based on the existing value of the controlling field.

Feels hacky, but it feels less hacky than exposing the form field for the sake of triggering the dependee and then hiding it via css.

GarChris’s picture

I have a similar problem where "Administer Organic groups permissions" is required for conditional fields to function properly. The dependent fields Reference taxonomy terms via Hierarchical Select widget and are normally exposed only when selected from a drop-down list (dependee prepopulated via url). Without Administer groups permission all fields are exposed.

sthomen’s picture

--- conditional_fields.module.orig      2017-10-10 15:28:37.262431300 +0300
+++ conditional_fields.module   2017-10-10 15:28:56.362803500 +0300
@@ -436,7 +436,7 @@
     }

     $dependent_location = array_merge($dependent_info['field_parents'], array($dependent));
-    $dependent_form_field = drupal_array_get_nested_value($form, $dependent_location);
+    $dependent_form_field = &drupal_array_get_nested_value($form, $dependent_location);

     // Cycle the dependant's dependees.
     foreach ($dependent_info['dependees'] as $dependency) {

This seemed to fix it for me.

ngommenginger’s picture

I got the same issue, and sthomen's solution also seems to fix it correctly for me.

trumanru’s picture

Status: Active » Reviewed & tested by the community

Seems like a completed solution.

casperone’s picture

I have this issue and attempted #4 (sthomen).. it did not seem to resolve the issue.

To confirm, I am just adding the "&" infront of "drupal_array_get_nested_value..."

e.g. $dependent_form_field = &drupal_array_get_nested_value($form, $dependent_location);

marleo’s picture

Patch didn't work for me. Instead of the conditional field always being visible for non-admin user (it should have been hidden), the patch made the field never display. Solution was to give that user role edit access to the dependee field and hide with CSS. Not ideal but functional.

tim-diels’s picture

Status: Reviewed & tested by the community » Needs work

There is no actual patch and last 2 comments mention it does not work.

mnovoa’s picture

Hello, any method to solve this problem?

dqd’s picture

Version: 7.x-3.0-alpha1 » 7.x-3.x-dev

Thanks for the report and all the efforts in here. But due to upcoming EOL of Drupal 7 consider this being closed soon. Feel free to re-open as "Needs review" then, if you found a solution or have a patch to be reported to help others.

Apart from that: please reroll newer patches against latest 7.x dev and we will see if we can still commit it before EOL of Drupal 7.

RichardDavies’s picture

Version: 7.x-3.x-dev » 4.0.0-alpha5

I'm experiencing the same issue with Drupal 10 and Conditional Fields v4. So I think this should remain an open issue.

dqd’s picture

Version: 4.0.0-alpha5 » 7.x-3.x-dev
Status: Needs work » Postponed

Thanks for the report @RichardDavies. Very much appreciated.

Since Drupal 10 and Conditional fields 4.0 are very different new branches with different code, I recommend to please open a new issue with a report, a summary and steps to reproduce. And make sure that no other module with issues is in the way. And please file issues always against latest dev branch, because this is the branch where upcoming releases are based on. Thanks for your efforts and please keep posting. +1

RichardDavies’s picture

@dqd You just barely said in your previous comment that you're considering closing this issue since Drupal 7 is EOL soon. Why not just repurpose this existing ticket (with all it's history) for the same issue with D10 and Conditional Fields 4.0? Seems pointless to close this ticket and reopen a new one for the same issue.

dqd’s picture

Title: Conditional Fields does't work properly with Field Permissions Module » Support for Field Permissions Module
Category: Bug report » Feature request
Issue summary: View changes
Status: Postponed » Postponed (maintainer needs more info)
Issue tags: -Field Permissions

@RichardDavies: it's rather pointless to keep it. Sorry, not meant any offensive, but: Why do you use (waste) your resources for a destructive discussion on this? To not open a new ticket? I open and close many tickets a day... I tried to explain why. And I can't take too much time for further explanation. The code base of Drupal 9/10 we hook into is completely different, Conditional fields 4.x is completely different because of that, the PHP version support has drastically changed and simply not one single comment in here would help it nor is here any patch or code to keep. Any references we maybe build to other issues will be in the 8++ universe, build on top of Symfony. Drupal 7 is a complete other software and Drupal's issue future moves to Gitlab, you know that, right?

I reviewed / responded / fixed / closed / commented / committed / cleaned up all together all over ~200 issues including 10 RTBC's over last weekend with about maybe less than 2 or 3 hours sleep and it became more issues the last two days on top to make the first Drupal 10 ready BETA release. And I have inflammations in the eyes, shoulder and hand and my laptop smokes... I have to close the Drupal 7 version of this project until January 2025 and just wanted to make sure that all leftovers not fixed before in D7 life circles will come over to the next generation.

Is that enough explanation for you? Would you please then be so kind and help me by doing what I have very kindly asked you for? Thanks for understanding.

Apart from that you brought my eyes back in this issue and there are questions raising:

Then as an other user having another role (who has edition rights on my test node of course), I edit the node. I can't have access to the boolean field with this role, but the boolean was set to false when I saved it as admin.

... indicates that this issue maybe is not in the CF's scope. And I see that you have cross posted this issue content from here with almost 100% the same text and context over there: #3425909: Doesn't work properly with Field Permissions module what indicates that this is maybe rather a field permission module issue and how it incorporates with other modules in its scope. So, for anyone reading please:

If you are sure this an issue of this project: File a new issue for the latest 4.x dev, show exactly how to reproduce that CF is not working with the field permission module and (in best case) give us an idea where to look at and what to change to get this fixed.

Thanks for understanding...