Conditional field works perfectly when you use nodes.

But when the node is of type user profile that is created with the Content Profile module, the registration does not validate fields.


peterpoe’s picture

Title:Conditional fields not validation in profile content type» Compatibility with Content Profile module
Version:6.x-1.0-beta2» 6.x-2.x-dev
Category:bug» feature
Bilmar’s picture


roball’s picture

Version:6.x-2.x-dev» 6.x-2.0-beta1

For me conditional fields on user profile nodes do work with 6.x-2.0-beta1, but only on the node/[NID]/edit pages, not when adding a new user with the user profile fields embedded into the user/user/create page.

Is there any way to get it working also on the user/user/create pages? Thanks!

roball’s picture

Assigned:Unassigned» eloiv
Category:bug» feature
Status:Reviewed & tested by the community» Active

Conditional fields still do not work on user/user/create pages with 6.x-2.0-beta2. Any chance to get this working until the final 2.0 release?


nod_’s picture

Version:6.x-2.0-beta1» 6.x-2.0-beta2
Status:Active» Needs review
new485 bytes

That patch makes it work on user/registration and user/create, but it doesn't check that conditional fields is actually required.

roball’s picture

Status:Needs review» Reviewed & tested by the community

Yeah, great, can confirm that after applying this patch Conditional fields work on user/user/create :-) Thank you!

Also I have no problems with required conditional fields.

I think the patch should get committed.

nod_’s picture

Status:Reviewed & tested by the community» Needs review
new1.16 KB

there was still a little issue, got sorted out by explicitly casting to (array). It should be good now.

roball’s picture

Status:Needs review» Needs work

I have reverted your original patch from #5 and applied the updated one from #7 and did some tests with more than one required conditional fields. The current patch worked as well as the original one, requiring the first required conditional field, but ignoring the second one on node save. On the first node edit, the second required conditional field was in fact required so you had to select something while editing, but didn't need to do so on creating the node (user).

Thanks anyway for your efforts!

Poieo’s picture


stephesk8s’s picture

The patch in #7 worked great for me. Thanks!

abaddon’s picture

Assigned:eloiv» Unassigned
Category:feature» bug
Status:Needs work» Needs review
new2.08 KB

the patch in #7 works if you only have 1 content profile on the registration page or if the one that has conditional fields is the first one (as far as i can tell)
i had 2 content profile types and the second one had the conditional fields, problem is that the after build function checks only on the first one.. this is fixed in my patch
i also made a small fix to the form_alter hook to use the same function the module already used on nodes (same functionality though, at least right now.. that function just sets the after build hook)

please review this with only 1 content type and let me know how it works then.. also, i dont have any required fields that are conditional, so i didnt test that

jjwhitney’s picture

Thumbs up from me! I've also confirmed that it works for required fields that are conditional.

loze’s picture

I can confirm that #11 works with required fields, and one or two content profile types.

roball’s picture

Then the status could be changed to RTBTC?

abaddon’s picture

Status:Needs review» Reviewed & tested by the community
jjwhitney’s picture

Status:Reviewed & tested by the community» Needs work

Whoops... I thought this was fixed, but there's still a problem (though it's certainly a step in the right direction): If two or more content profiles have conditional fields, only the first set will work, because conditional_fields_add_js() only works the first time it's called (line 810 after applying abaddon's patch).

* Adds javascript to the node editing form
function conditional_fields_add_js($settings) {
  // Avoid adding js twice when the node form has failed validation
  static $js;
  if (!$js) {
    drupal_add_js(array('ConditionalFields' => $settings), 'setting');
    drupal_add_js(drupal_get_path('module', 'conditional_fields') . '/conditional_fields.js');
    $js = TRUE;
jjwhitney’s picture

Status:Needs work» Needs review
new5.66 KB

I've generated a new patch that should fix this final problem. Please give some feedback!

jjwhitney’s picture

new5.06 KB

Ooops... I made a small typo and I accidentally put one of my other fixes into that last patch. Try this one instead.

filiptc’s picture

Status:Needs review» Reviewed & tested by the community

Nice job! #18 works like a charm! =)

deggertsen’s picture

Not sure why but patch #18 did not work for me but it didn't. I also tried most of the other patches too with no success. I'm only testing on the registration page so I'm not sure if other pages are working or not.

nicholas.alipaz’s picture

subscribing, was on the duplicate bug and want to follow this thread too.

jjwhitney’s picture

deggertsen... Could you tell us a bit more about your situation? Is it possible to replicate your problem on a fresh Drupal 6 install? If so, I'll try to get it figured out for you.

deggertsen’s picture

I'll try to just reinstall when I get a chance and see if it will work then and let you know. Hopefully today...

deggertsen’s picture

Just uninstalled and reinstalled with patch #18 and everything works wonderfully! Sorry to cause any doubt...


aaki’s picture

It's working like a charm for me too. Using drupal 6.20, content profile 1.0 and the patched (#18) version of conditional fields 2.0-beta2. I'm wondering that it is not in dev already?

Anyway, jjwhitney, thanks a lot!

aaki’s picture

Oh, one thing. If you're using drupal_get_form('user_register') in your template or in a preprocess function you have to make sure the additional JS is loaded. Then conditional field is working on those forms too.

function my_module_or_theme_preprocess_page(&$vars) {
  if ($vars['is_front']) {
    //adding the user_login form
    $vars['form_user_login'] = drupal_get_form('user_login');
    //adding the user_register form
    $vars['form_user_register'] = drupal_get_form('user_register');
    // make sure additional javascript that was added in hook_form_alter is also loaded
    $vars['scripts'] = drupal_get_js();
drupalisme’s picture

Assigned:eloiv» Unassigned
Category:feature» bug
Status:Active» Reviewed & tested by the community

After apply #24 then Patch #18 works fine! RTBC to 6.x-beta3?

MXT’s picture

Patch in #18 works very well for me, in user registration page.

Can this be committed ?

Thank you very much

ss54’s picture

I would be so grateful if you would teach me how to apply this patch; where to insert. Thanks

abaddon’s picture
theres some page on but i cant find it, i found something GIT specific and its not what you want

continue in the support forum, this isnt the proper place to ask

ss54’s picture

Thanks abaddon, I found how to apply a patch on the the conditional_fields module, but the issue now is that the patch is not being implemented successfuly. I am getting an error when I am applying the patch

abaddon’s picture

new4.98 KB

the patch in #18 applies cleanly to conditional_fields-6.x-2.0-beta2 but with -p1 instead of -p0, heres an edited patch that should work with the default -p0 (does windows have -p? sorry i only have linux)
and i didnt test the patch, just edited for -p0

make sure you apply it to the proper version of the module, and not an older one

duvien’s picture

Nice work. I was using content profile and needed conditional fields to work on registration form (frontend). It was okay in edit form but your patch help to make it work on on both so thank you.

using this patch with:
conditional fields 6.x-2.0-beta2
content profile 6.x-1.0

max0u’s picture


I have applied the patch below (32), that is what I get :

conditional_fields_6_0.patch:21: trailing whitespace.

Checking patch conditional_fields.module...
Applied patch conditional_fields.module cleanly.
warning: 1 line adds whitespace errors.

But fields are staying disabled when adding a new user. Even if when I activate the controller field.
Any idea ?

Rectif : Not working when controlling a "Group", but it is working when controlling directly a field.

capellic’s picture

I applied the patch in #32 cleanly and works!!

int_ua’s picture

No problems detected after patching from #32 :)

roball’s picture

So could this please get committed?

andiart’s picture

for me it also doesn't work. i have two content profiles for 2 different registration procedures. for choosing the right profile in login I use autoassign role

roball’s picture

Version:6.x-2.0-beta2» 6.x-2.0
Priority:Normal» Major

Unfortunately, the final 6.x-2.0 has been released now without including this patch :-( After trying it out I realised that it does NOT work with content profile fields, and this thread's patches no longer can be applied either. So I had to revert back to 2.0-beta2 with the patch #18, which is working fine.

@abaddon: Patch #18 is alright - since Drupal's revision control is Git based patches must be in -p1 format (and no longer in -p0).

roball’s picture

Status:Reviewed & tested by the community» Patch (to be ported)

Since patch #18 cannot be applied to 6.x-2.0, can anybody please port it to work again with the latest official release?

GaëlG’s picture

Here's the new patch.

roball’s picture

Status:Patch (to be ported)» Reviewed & tested by the community

Excellent, patch #41 works perfectly with 2.0. Thank you. Hoping that it finds the way to the official code one day.

roball’s picture

Title:Compatibility with Content Profile module» Make Conditional Fields compatible with Content Profile module (working patch available)
arcovia’s picture

Issue tags:+module update

As 1.1 is not supported any more, any website may fail after security update from 1.1 to 2.0.

Patch #41 works fine, thank you!

roball’s picture

Not sure about which security update you are speaking.

Hope to see this patch finally applied in 2.1.

Encarte’s picture


lucascaro’s picture

works like a charm for 6.x-2.0!

roball’s picture

Yes, but still needs to be committed!

roball’s picture

Any chance to get this patch committed? It is urgently needed.

Anonymous’s picture

Is there a reason this patch hasn't been committed yet??

filiptc’s picture

Version:6.x-2.0» 6.x-2.x-dev
Status:Reviewed & tested by the community» Needs work

Latest dev version (2012-02-03) introduces modifications that make patching useless (even when applying manually).

lucascaro’s picture

Component:Compatibility w/ other modules» User interface

since #648934 and this issue have 2.5 years and there's not much advance in the other one, maybe it's worth to create a new patch and commit it for now?

I'll get into that since I need the functionality and I'll post it back here.


lucascaro’s picture

Title:Make Conditional Fields compatible with Content Profile module (working patch available)» Make Conditional Fields compatible with Content Profile module
Status:Needs work» Needs review

Well, it seems that making it work with content profile was easier than I thought. here's a patch to get this rolling, it works for my use case but it might need more work for other people.

Anyone care to review?

lucascaro’s picture

and yes, the patch.

elly’s picture

NM, patched the wrong version

lucascaro’s picture

pinging the maintainers for any feedback about this patch?

roball’s picture

Component:User interface» Compatibility w/ other modules

Changing the Component to "Compatibility w/ other modules". I am also waiting for maintainer feedback, now for almost 2 years...

peterpoe’s picture

Status:Needs review» Needs work

The patch does not fix the issue. Content Profile does not add #after_build callbacks when taking over the node form, so I fear there is very little we can do except trying to get this issue #826126: Add in #after_build callbacks to $form reopened and fixed.

peterpoe’s picture

Status:Needs work» Fixed

Ok, never mind the last comment. The patch was good and fixes the problem, so I committed it (with an additional check for the existence of the #content_profile_registration_use_types property). Thanks to everyone involved and sorry for the long wait!

lucascaro’s picture

awesome! thanks :)

Status:Fixed» Closed (fixed)

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

roball’s picture

Can confirm that the commit to 6.x-2.x in fact fixed the problem. The current dev (6.x-2.0+12-dev) is working fine in supporting the Content Profile module. Thanks!

ashvin_drupal’s picture

Status:Closed (fixed)» Needs review


above patch working fine on contact profile module with conditional but, one issue generate as per below :

I have a user registration form which contain profile fields and some conditional fields with dependency on group selection as per show some fields and some hide as well . When form submit than hidden fields (which is currently hide) validate, also. Display error message to provide hide fields values as well.
So, Please can anybody help me to sort-out this issue

roball’s picture

Status:Needs review» Closed (fixed)

This issue is fixed, so please don't re-open it just for asking support. You have already created an own issue for that.