In previous dev versions of Conditional Fields, I was able to make a field unavailable using the "Field Permissions" module and ensuring that "Hide the dependent if the dependee is not in the form" was checked.

In the current dev version, I get the following errors when I try to to add content to an affected content type when the dependee is unavailable to the role in question:

Notice: Undefined index: field_target_or_actual in conditional_fields_form_after_build() (line 436 of /var/www/dev/ppnyc/sites/all/modules/conditional_fields/conditional_fields.module).
Recoverable fatal error: Argument 2 passed to drupal_array_get_nested_value() must be an array, null given, called in /var/www/dev/ppnyc/sites/all/modules/conditional_fields/conditional_fields.module on line 437 and defined in drupal_array_get_nested_value() (line 6348 of /var/www/dev/ppnyc/includes/common.inc).
Files: 
CommentFileSizeAuthor
#6 1269602-conditional_fields-save-modified-field-back-into-form.patch885 bytestheo_
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]
#1 conditional_fields-1269602-field_level_permissions.patch3.63 KBBarisW
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch conditional_fields-1269602-field_level_permissions.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

BarisW’s picture

Status:Active» Needs review
StatusFileSize
new3.63 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch conditional_fields-1269602-field_level_permissions.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

I have the same issue (with OG field access).
This patch fixes this. I've changed:

<?php
$dependee
= $dependency['dependee'];
$dependee_info = $form['#conditional_fields'][$dependee];
?>

Into:

<?php
$dependee
= $dependency['dependee'];
// If the dependee is not part of the form (due to permissions),
// continue to the next conditional field.
if (!isset($form['#conditional_fields'][$dependee])) {
  continue;
}
$dependee_info = $form['#conditional_fields'][$dependee];
?>

The rest of the patch is just Drupal Code styling (removed unneeded spaces after some lines).

peterpoe’s picture

Status:Needs review» Fixed

This was fixed in commit 890c237.

Status:Fixed» Closed (fixed)

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

warmth’s picture

Status:Closed (fixed)» Active

Sorry but this doesn't seem to be completely fixed. I hid the main dependee (using Field Permissions) for all the users but anonymous so they can only select that option when they are signing up but no longer change it when they try to edit their profiles, because that auto assign the role.

The registration process go perfectly but when they go to edit their profile, where the main dependee is hidden, the dependents are all showed and if they are required the user won't be able to save their profile changes without filling them up. I tested making the dependee visible and then all the depedents are correctly hidden and toggled when editing but that way the users can change the main dependee but their role won't change, so I will be in troubles. Please help me.

albert9000’s picture

Okay this sounds simple but it works.

Broken example:

[required dependent] is invisible when [dependee] has at least one of the values: option1, option2.

Working example:

[required dependent] is visible when [dependee] has none of the values: option1, option2.

This is a reversal of thinking but it works.

theo_’s picture

Issue summary:View changes
StatusFileSize
new885 bytes
PASSED: [[SimpleTest]]: [MySQL] 160 pass(es).
[ View ]

I faced a similar issue where conditional fields doesn't apply when user doesn't have edit access to the dependent field.

To reproduce:
* Setup a conditional field: dependent field is be visible when dependee field has value [option1], also check "Hide the dependent if the dependee is not in the form"
* Using Field Permissions, remove access to edit own dependent field
* Go to creation form, notice that (dependent) field is always displayed and conditional fields doesn't applied even when dependee field has value [option1]

I found that this bug occur in conditional_fields_form_after_build() this function is in charge of applying conditional field on creation forms. It uses drupal_array_get_nested_value() to retrieve and alter the dependent field but it his not modified back into the form using drupal_array_set_nested_value() because when you don't have access to the field is just skip this step.

Here is a patch which fix the issue

theo_’s picture

Component:Compatibility w/ other modules» Code
Status:Active» Needs review

The last submitted patch, 1: conditional_fields-1269602-field_level_permissions.patch, failed testing.