Currently profile2 conditions work at admin/people/create, but not at user/1/edit/main for example.
The problem is that profile2 defines that it works with entities at the latter case, under $form_state['complete form']['profile_[name]'], so

if (!isset($form_state['complete form']['#entity_type'], $form_state['complete form']['#bundle'])) {

this check fails silently.
I have a patch to discover entities from one level deeper (assuming still that one form - one dependency set)
Maybe some more solid approach is needed, but it's sure there is something to do here.
Files: 
CommentFileSizeAuthor
conditional_fields_profile2.patch1.39 KBAron Novak

Comments

This Patch does seem to have fixed the issue.

Marked #1215670: Conditional Fields not working with Profile2 in D7 as duplicate of this.
Also, for reference, see the profile2 sister issue at #1288524: Compatibility with Conditional Fields

The patch works for me too.

Status:Needs review» Reviewed & tested by the community

Works for me as well. Good job.

Let's have this committed.

GREAT!
thx!

patch works for me! thank you!

patch works for me. thx!

Patch doesn't work for me. Running latest dev builds of Entity, Conditional Fields and Profile2 and still receiving the following error when trying to add conditions to profile fields. It worked just fine before I auto updated - so the last version of one or all of these was great. Even with the patch here it still gives me the following:

Error messageEntityMalformedException: Missing bundle property on entity of type profile2. in entity_extract_ids() (line 7389 of /home/[...]/includes/common.inc).
The website encountered an unexpected error. Please try again later.

Thanks for any help you can give--

same problem, same solution. thank u!

Tested and working with Profile2 7.x-1.2 and Entity 7.x-1.0-rc1.

Attempted to duplicate the errors in #8 by using current devs on both Profile2 and Entity, but I did not get any errors. Worked perfectly even with the devs. Errors may be caused by another module.

Thanks, Aron.

@goatsee:
You say:

It worked just fine before I auto updated - so the last version of one or all of these was great. Even with the patch here it still gives me the following:

Does this mean you applied the patch and it was working, then you auto updated the module and now it is not working?

If so that is because your updating the module will have given you an unpatched version again.
Every time you update the module you have to re-apply the patch (unless it has been committed in the latest version).

Status:Reviewed & tested by the community» Fixed

I just pushed a fix to this inspired from Aron Novak's and mr.yorks' (#1440822: Compatibility with profile2 and fields_collection) patches, but with a different approach: we now skip checking if we are in an "entity form" altogether. The reason is, that after all there is no such thing as an "entity form". If two fields with dependencies are found in a form, conditional fields information is attached to them regardless of the form type. I hope that this change doesn't cause regressions elsewhere, but this is fixed.
Thanks everyone!

Status:Fixed» Closed (fixed)

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

Still not working for me. Using latest dev version of Conditional Fields with Drupal 7.12.

Notice: Undefined index: und in conditional_fields_evaluate_dependencies() (line 1020 of C:\wamp\www\drupal\sites\all\modules\conditional_fields\conditional_fields.module).

UPDATE:

Ok I got mine working. not sure if this will help others but here is the change I made.

On line 1020 change:

$values = $dependee_values_location[$dependee_form_field['#language']];

to

$values = $dependee_values_location[$dependee_form_field['#field_name']][$dependee_form_field['#language']];

Even after trying #14's fix (thanks for the suggestion esentrik!) I still can not get this to work. esentrik's solution gets rid of the errors, but Conditional Fields does not actually save the value to the DB.

Category:task» bug
Priority:Normal» Critical
Status:Closed (fixed)» Active

I also tried #14's fix but I still get the same error.

What's interesting is that the same exact error is seemingly being thrown at different place also:

In my profile 2 type I have a field for phone numbers, to which you can add multiple values. Further down the form there is a field collection with fields which are using conditional fields.

When you hit "add another number" the error gets thrown,

Notice: Undefined index: und in conditional_fields_evaluate_dependencies() (line 1020...of

and

Notice: Undefined index: field_MYFIELDNAME in conditional_fields_evaluate_dependencies() (line 1020 of .../sites/all/modules/conditional_fields/conditional_fields.module).

Both those fields are still empty since they are farther down on the form. Does adding another item to a list field validate the whole form? Why is the phone field (which has no conditional form module association) triggering the error on the other fields?

I applied #14 and it worked for me, but just for profile2 entities, no more for node.

So i replaced line 1020 with

if ($form['#form_id'] == 'user_profile_form'){
$values = $dependee_values_location[$dependee_form_field['#field_name']][$dependee_form_field['#language']];
} else
$values = $dependee_values_location[$dependee_form_field['#language']];

and now it works for me.

Priority:Critical» Normal
Status:Active» Fixed

The original issue was fixed.
There is a patch here http://drupal.org/node/1562760#comment-6287750 with a possible fix to the issue reported in #14 (please help testing!).

Status:Fixed» Closed (fixed)

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

Status:Closed (fixed)» Active

It looks that the problem is still not fixed when using standard Drupal Commerce profiles with conditional fields.