Hello,

how can i set the default value in subform?

I made this, but with no effect.
$form['nodes'][$i] = array(
'#type' => 'subform',
'#subform_id' => 'lesson_plan_node_form',
'#subform_file' => array('module' => 'node', 'name' => 'node.pages'),
'#subform_arguments' => array(clone $node),
'#default_value'=>array('title'=>array('#value'=>$tytul_plan), 'field_klasa_ref'=>array('und'=>array('#value'=>$klasa))),
'#subform_default_triggering_element' => array('actions', 'submit'),
'#required' => FALSE,
);

Ania

Comments

usdv’s picture

Issue summary: View changes

I think there is no #default_value in 'subform' form element definition at all. I faced with similar problem when I was making complex multistep form with ajax. I resolve this problem by passing into $form_state['input'] values array of subform. Try to do something like this:
$form_state['input']['subform_element_name'] = $subform_element_values
I'm not sure how it will work with non flat form values array, but it works well for me.

Hope it helps. This module is cool.