Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
conditional_fields_profile2.patch | 1.39 KB | Aron Novak | |
Comments
Comment #1
webadpro CreditAttribution: webadpro commentedThis Patch does seem to have fixed the issue.
Comment #2
rooby CreditAttribution: rooby commentedMarked #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
Comment #3
rooby CreditAttribution: rooby commentedThe patch works for me too.
Comment #4
xmacinfoWorks for me as well. Good job.
Let's have this committed.
Comment #5
NaZg CreditAttribution: NaZg commentedGREAT!
thx!
Comment #6
nevosa CreditAttribution: nevosa commentedpatch works for me! thank you!
Comment #7
Svekke CreditAttribution: Svekke commentedpatch works for me. thx!
Comment #8
goatsee CreditAttribution: goatsee commentedPatch 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--
Comment #9
dgastudio CreditAttribution: dgastudio commentedsame problem, same solution. thank u!
Comment #10
cwithout CreditAttribution: cwithout commentedTested 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.
Comment #11
rooby CreditAttribution: rooby commented@goatsee:
You say:
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).
Comment #12
peterpoe CreditAttribution: peterpoe commentedI 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!
Comment #14
jlongbottom CreditAttribution: jlongbottom commentedStill 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']];
Comment #15
MD3 CreditAttribution: MD3 commentedEven 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.
Comment #16
digitopo CreditAttribution: digitopo commentedI 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,
and
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?
Comment #17
puiduI 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.
Comment #18
peterpoe CreditAttribution: peterpoe commentedThe 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!).
Comment #20
FiNeX CreditAttribution: FiNeX commentedIt looks that the problem is still not fixed when using standard Drupal Commerce profiles with conditional fields.
Comment #21
george.plescan CreditAttribution: george.plescan commentedThe 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).
Comment #23
dqdThis has been committed for 8.x and above but forgotten to be set as "fixed". Apart from that:
Thanks for the report and all the efforts in here. But due to inactivity in this issue for some years and because of the upcoming EOL of Drupal 7, I will close this issue on the way by cleaning up the issue queue.
Feel free to re-open as "Needs review" if you found a solution or have a patch to be reported to help others on this outdated version.
If you think this issue or missing feature should be addressed in a newer Drupal core 8 and above compatible version of this project, then please file a new issue to the latest dev.
Comment #24
dqd