I’ve been having troubles with form_set_value(). I’ve extended the Search form, everything works, but after submission, the form values for those fields added by me return to default (see the code).
What am I doing wrong?
Thank you!
<? /** * implementation of function hook_form_FORM_ID_alter */ function myModule_form_search_form_alter( &$form, &$form_state, $form_id ){ $form['myM_options']['entity'] = array( '#type' => 'radios', '#title' => 'Search by', '#default_value' => 'gene', '#options' => array( "gene" => "Genes", "ortholog" => "Orthologs", "microarray" => "Microarray Features" ), ); $form['myM_options']['plant'] = array( '#type' => 'checkboxes', '#title' => 'Choose plants', '#options' => formatPlants(), // select all checkboxes by default '#default_value' => array_keys(formatPlants()), ); $form['#validate'][] = 'myModule_search_validate'; $form['#submit'][] = 'myModule_search_form_alter_submit'; } /** * validation functoin */ function myModule_search_validate( $form, &$form_state ){ // this works as expected form_set_value($form['basic']['processed_keys'], trim($form_state['values']['keys']), $form_state); // this doesn't !!! form_set_value($form['myM_options']['entity'], $form_state['values']['entity'], $form_state); form_set_value($form['myM_options']['plant'], array( 'id_1', 'id_2' ), $form_state); }