Hey there, here is the setup I have:

One controlling field which allows for multiple values :

test field 1 = select field multiple values
value 1
value 2

Controlled fields
child field 1 appears when value 1 is selected in test field 1
child field 2 appears when value 2 is selected in test field 2

So if I enter values in the two child fields the values are saved on the nodes, I can see in the node load:

field_child_field_1

Array
(
[0] => Array
(
[value] => value test field 1
)

)

field_field_child_2

Array
(
[0] => Array
(
[value] => value test field 2
)

)

But it's not displayed on the node view...

So this seems like some display bug, any idea what's up?

Attached is the export of my cck content type I used for testing.

$content[type] = array (
'name' => 'test',
'type' => 'test',
'description' => '',
'title_label' => 'Titre',
'body_label' => 'Corps',
'min_word_count' => '0',
'help' => '',
'node_options' =>
array (
'status' => true,
'promote' => true,
'sticky' => false,
'revision' => false,
),
'comment' => '2',
'event_nodeapi' => 'never',
'forward_display' => 1,
'privatemsg_link' =>
array (
'node' => false,
'teaser' => false,
'comment' => false,
),
'signup_node_default_state' => 'disabled',
'prepopulate_allowed' => 1,
'old_type' => 'test',
'orig_type' => '',
'module' => 'node',
'custom' => '1',
'modified' => '1',
'locked' => '0',
'fivestar' => 0,
'fivestar_stars' => 5,
'fivestar_labels_enable' => 1,
'fivestar_label_0' => 'Cancel rating',
'fivestar_label_1' => 'Poor',
'fivestar_label_2' => 'Okay',
'fivestar_label_3' => 'Good',
'fivestar_label_4' => 'Great',
'fivestar_label_5' => 'Awesome',
'fivestar_label_6' => 'Give it @star/@count',
'fivestar_label_7' => 'Give it @star/@count',
'fivestar_label_8' => 'Give it @star/@count',
'fivestar_label_9' => 'Give it @star/@count',
'fivestar_label_10' => 'Give it @star/@count',
'fivestar_style' => 'average',
'fivestar_text' => 'dual',
'fivestar_title' => 1,
'fivestar_unvote' => 0,
'fivestar_position_teaser' => 'hidden',
'fivestar_position' => 'below',
'fivestar_comment' => 0,
'gcg_node_type_enabled' => 0,
'gcg_node_result_format' => 'system',
'gcg_node_result_on_map' => '-1',
'gcg_node_result_map_height' => '-1',
'gcg_node_disabled' => '-1',
'gcg_node_custom_result' => '-1',
'gcg_node_required' => '-1',
'gcg_node_required_accuracy' => '-1',
'gcg_node_privacy' => '-1',
'gcg_node_required_privacy' => '-1',
'location_maxnum' => '0',
'location_defaultnum' => '0',
'location_weight' => '9',
'location_collapsible' => 1,
'location_collapsed' => 1,
'location_addanother' => 0,
'location_name' => '',
'location_street' => '',
'location_city' => '0',
'location_province' => '0',
'location_postal_code' => '0',
'location_country' => '1',
'ant' => '0',
'ant_pattern' => '',
'ant_php' => 0,
);
$content[fields] = array (
0 =>
array (
'widget_type' => 'options_select',
'label' => 'test field parent',
'weight' => '-4',
'description' => '',
'default_value_widget' =>
array (
'field_test_field_parent' =>
array (
'keys' =>
array (
0 => '',
),
),
),
'default_value_php' => '',
'group' => false,
'required' => '0',
'multiple' => '1',
'text_processing' => '0',
'max_length' => '',
'allowed_values' => 'Test value 1
Test value 2',
'allowed_values_php' => '',
'field_name' => 'field_test_field_parent',
'field_type' => 'text',
'module' => 'text, optionwidgets',
'default_value' =>
array (
0 =>
array (
'value' => '',
),
),
),
1 =>
array (
'widget_type' => 'text',
'label' => 'child field 1',
'weight' => '0',
'rows' => '1',
'description' => '',
'default_value_widget' =>
array (
'field_child_field_1' =>
array (
0 =>
array (
'value' => '',
),
),
),
'default_value_php' => '',
'group' => false,
'conditional_fields' =>
array (
'field_test_field_parent' =>
array (
'Test value 1' => 'Test value 1',
),
),
'required' => '0',
'multiple' => '0',
'text_processing' => '0',
'max_length' => '',
'allowed_values' => '',
'allowed_values_php' => '',
'field_name' => 'field_child_field_1',
'field_type' => 'text',
'module' => 'text',
),
2 =>
array (
'widget_type' => 'text',
'label' => 'field child 2',
'weight' => '0',
'rows' => '1',
'description' => '',
'default_value_widget' =>
array (
'field_field_child_2' =>
array (
0 =>
array (
'value' => '',
),
),
),
'default_value_php' => '',
'group' => false,
'conditional_fields' =>
array (
'field_test_field_parent' =>
array (
'Test value 2' => 'Test value 2',
),
),
'required' => '0',
'multiple' => '0',
'text_processing' => '0',
'max_length' => '',
'allowed_values' => '',
'allowed_values_php' => '',
'field_name' => 'field_field_child_2',
'field_type' => 'text',
'module' => 'text',
),
);

Comments

clemens.tolboom’s picture

Title: Bug when you have multiple values added on the form // using multiple values on the parent field » Not all fields with valid conditions are displayed when viewing node
StatusFileSize
new3.46 KB

A rephrase of the original bug:

With the attached content type with a simple.
- multi select A,C
- fields A_text, B_text, C_text
only the first (A_text) is displayed when multi select values are A,B,C.

Display is

condition: 
Fields A
Fields C

A_text: 
A

So missing is

C_text:
C

clemens.tolboom’s picture

StatusFileSize
new4.52 KB

I'm working on a patch ... here is a nodetype with groups. It's the same nodetype but now with group_a and group_b

clemens.tolboom’s picture

Status: Active » Needs review

-- empty on purpose (deleted old text which was useless) --

clemens.tolboom’s picture

Status: Needs review » Postponed (maintainer needs more info)

Trying to provide a fix.

clemens.tolboom’s picture

Status: Postponed (maintainer needs more info) » Needs work
StatusFileSize
new1.78 KB

I put all values of control_field into parameter $selected_values when calling conditional_fields_is_triggered().

But I'm not sure whether this works in all cases. So please test!!!

This code works NOT when using taxonomy_field together with patch #250748: Integrate with Content Taxonomy.

So maybe I'm wrong :-/

patchak’s picture

Yes I can confirm this patch works when using normal text selects as controller fields. But it does not work when using taxonomy fields as a controller field.

Furthermore if I use a taxonomy field as a controller, it won't show the value of ANY of the child fields, if I have more than one field. If I have only one conditionnal field with a taxonomy field as a parent, then the field's value will show, but not the label of the field.

I added this patch over the other one for taxonomy field, and indeed it does not work....

Anything you could do about this??
Patchak

peterpoe’s picture

Status: Needs work » Needs review
StatusFileSize
new2.68 KB

Here's a patch that handles orphaned fields as well.

patchak’s picture

This patch works for me, I think it should be commited and maybe a release should be done at this point so it would easier to follow???

Patchak

peterpoe’s picture

Committed and included in the new 0.1-ALPHA1 release (yes I'm beign cautios :) )
Thanks!

peterpoe’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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