Hi,
I'm trying to build a complex conditional form with fieldgroup multipage but i'm unable to show groups of fields after an option (from a list of checkboxes) has been ticked.
Is a custom module that implement an entity and fields.
This is the group:
$field_group = new stdClass();
$field_group->disabled = FALSE;
$field_group->api_version = 1;
$field_group->identifier = 'group_raw_materials|organisation|organisation|form';
$field_group->group_name = 'group_raw_materials';
$field_group->entity_type = 'organisation';
$field_group->bundle = 'organisation';
$field_group->mode = 'form';
$field_group->parent_name = 'group_specific';
$field_group->data = array(
'label' => 'Raw Materials',
'weight' => '0',
'children' => array(
0 => 'hub_rawmaterials_resins',
1 => 'hub_rawmaterials_fibres',
2 => 'hub_rawmaterials_consumables',
3 => 'hub_rawmaterials_core',
),
'format_type' => 'div',
'format_settings' => array(
'label' => 'Raw Materials',
'instance_settings' => array(
'required_fields' => 1,
'id' => 'group-raw-materials',
'classes' => 'collapsidiv',
'description' => '',
'show_label' => '1',
'label_element' => 'h3',
'effect' => 'none',
'speed' => 'fast',
),
'formatter' => 'collapsed',
),
);
$info['group_raw_materials|organisation|organisation|form'] = $field_group;
This is the function I'm trying to use:
function organisationform_field_group_build_pre_render_alter(&$element) {
$element['group_wrapper']['group_specific']['group_raw_materials'] += array(
'#states' => array(
'visible' => array(
'#edit-hub-position-activities-und-raw-materials' => array('checked' => TRUE),
),
),
);
}
and this is what I get form my print_r function: (print_r($element['group_wrapper']['group_specific']['group_raw_materials'])
[#states] => Array
(
[visible] => Array
(
[#edit-hub-position-activities-und-raw-materials] => Array
(
[checked] => 1
)
)
)
So everything seems correct but the group is still showing.
I've also tried to downgrade fieldgroup with no better results.
I'm quite new in the module development and I'd appreciate any help.