I can't say with 100% certainty that this is a bug that exists for everyone because I have the fieldgroup_tabs module installed which requires some additional conditional_fields.module code tweaking to make it work. Maybe someone else can confirm this is happening for them without the fieldgroup_tabs module in use.

The potential bug seems to be in the determination of when a form element should be themed using cck's theme_content_multiple_values() function. The way conditional fields makes this decision is by testing if the form element has the '#conditional_fields_multiple' property set. This property is set in the following code segment for elements in groups:

// Manage multiple ahah fields
if ($form[$element][$group_element]['#theme'] == 'content_multiple_values') {
  $form[$element][$group_element]['#conditional_fields_multiple'] = TRUE;
}

The problem I am seeing is that the '#theme' property seems to always be an array whose '#theme' property is 'conditional_fields_form_item'. Therefore this if always returns false and the '#conditional_fields_multiple' property never gets set.

Since all cck add more #ahah fields have a "Add another item" button, I have gotten this to work by changing the code to check for the existence of this button instead of the '#theme' property. This is done as follows:

// Manage multiple ahah fields
if (isset($form[$element][$group_element][$group_element . '_add_more'])) {
  $form[$element][$group_element]['#conditional_fields_multiple'] = TRUE;
}

Again, this is the code I am using for the conditional fields within groups. I assume something very similar could be used for fields not within groups.

Hopefully this can be confirmed or someone can clarify that this issue only affects users of the fieldgroup_tabs module.

Comments

mitchell’s picture

Status: Active » Closed (duplicate)

Marking this as a duplicate of #206343: Compatibility with Fieldgroup tabs. Please continue the discussion and hopefully post a patch there :)