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.
conditional_fields_profile2.patch1.39 KBAron Novak


webadpro’s picture

This Patch does seem to have fixed the issue.

rooby’s picture

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

rooby’s picture

The patch works for me too.

xmacinfo’s picture

Status:Needs review» Reviewed & tested by the community

Works for me as well. Good job.

Let's have this committed.

NaZg’s picture


nevos’s picture

patch works for me! thank you!

Svekke’s picture

patch works for me. thx!

goatsee’s picture

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/
The website encountered an unexpected error. Please try again later.

Thanks for any help you can give--

kervi’s picture

same problem, same solution. thank u!

cwithout’s picture

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.

rooby’s picture

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

peterpoe’s picture

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.

jlongbottom’s picture

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


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']];


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

MD3’s picture

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.

digitopo’s picture

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


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?

puidu’s picture

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.

peterpoe’s picture

Priority:Critical» Normal
Status:Active» Fixed

The original issue was fixed.
There is a patch here 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.

FiNeX’s picture

Status:Closed (fixed)» Active

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

george.plescan’s picture

Issue summary:View changes

The solution doesn't seem to apply to the latest version of Conditional Fields.

I use Profile 2 7.x-1.3+4-dev with Conditional Fields 7.x-3.0-alpha1+12-dev.

Either the required fields are not enforced (if I make fields required on some field value), and if I try the other way (make fields optional) the fields are always required (even if hidden).

  • peterpoe committed d81c084 on 8.x-1.x
    Issue #1288522 by Aron Novak, mr.york: better compatibility with nested...