This issue is a follow on to the recently closed issue #619290: Make Conditional Fields compatible with Content Profile module. That issue's fix put in code to get the conditional fields node form function to fire off in the case of the user_register form. The problem that I ran into (and it was a real head scratcher) was where you had two content profiles used on the registration form. The site's organization registers users from different use cases. One being a participant and one for volunteers. We set up a general profile that holds contact info and other general stuff while the participant and volunteer profiles hold the things specific to their context. We are using the autoassignrole module in conjunction with content_profile to control which profiles show up on a registration form based on the path from which they enter the form. (So /participant/register gets profile + participant and /volunteer/register gets profile + volunteer.)

The trouble comes in with the conditional_fields_node_after_build function.

<?php
function conditional_fields_node_after_build($form, &$form_state) {
 
// Avoid running twice when the form is rebuilt with AHAH
 
if (!empty($form_state['clicked_button']['#ahah'])) {
    return
$form;
  }

 

$type_name = $form['type']['#value'];

 

// Do nothing if there are no conditional fields
 
if (!$data = conditional_fields_load_data($type_name)) {
    return
$form;
  }
?>

The $form['type']['#value'] data coming into the function holds only one content profile's type name. What had thrown me for a loop was that with the participant profile the conditional fields were working perfectly, but the volunteer were not getting picked up. Turns out that $form['type']['#value'] holds the first content profile type alphabetically. so participant was before profile, but volunteer was after. It got to the "if (!$data = " test and exited.

I put in a local hack to make it work for me, but we should find better general solution. My hack:

<?php
 
if ($type_name == 'profile') $type_name = 'volunteer';
?>

My hack is definitely not a good fix for anyone else as is, but I thought I would raise the issue in case others have a similar situation.

Comments

roball’s picture

Category:bug» feature

I think it may be easier to never use more than one content type associated to a content profile. You could just use conditional fields in that single user profile to distinguish between your use cases (participant or volunteer).