Not all fields with valid conditions are displayed when viewing node

patchak - April 24, 2008 - 13:28
Project:Conditional Fields
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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',
),
);

#1

clemens.tolboom - April 28, 2008 - 08:25
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

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
AttachmentSize
nodetype_250710.txt3.46 KB

#2

clemens.tolboom - April 28, 2008 - 09:07

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

AttachmentSize
nodetype_250710_group.txt4.52 KB

#3

clemens.tolboom - April 29, 2008 - 19:07
Status:active» patch (code needs review)

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

#4

clemens.tolboom - April 29, 2008 - 19:09
Status:patch (code needs review)» active (needs more info)

Trying to provide a fix.

#5

clemens.tolboom - May 14, 2008 - 12:07
Status:active (needs more info)» patch (code needs work)

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: Patch Content Taxonomy as controller field.

So maybe I'm wrong :-/

AttachmentSize
conditional_fields_view_fields_250710.patch1.78 KB

#6

patchak - May 17, 2008 - 13:58

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

#7

peterpoe - May 28, 2008 - 10:15
Status:patch (code needs work)» patch (code needs review)

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

AttachmentSize
conditional_fields_view_fields_250710_2.patch2.68 KB

#8

patchak - June 5, 2008 - 14:21

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

#9

peterpoe - June 27, 2008 - 12:16

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

#10

peterpoe - June 27, 2008 - 12:16
Status:patch (code needs review)» fixed

#11

Anonymous (not verified) - July 11, 2008 - 12:24
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.