Hello

I face an issue when fire ajax callback function in my coding. I have a select list and a text box. If there is any change in select list field, the text box will be updated by selected value. I added my code in form_alter function. But, it fired only one time. Below is my code.


function field_collection_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'employee_performance_node_form') {

$form['field_my_weight_select'][LANGUAGE_NONE]['#ajax']= array(
      'callback' => 'custom_test_entity_callback',
      'wrapper' =>'custom_test_entity_wrapper',
      'method' => 'replace',
      'effect' => 'fade',
      'event' => 'change',
    );

$form['field_text_for_test']['#prefix']='<div id="custom_test_entity_wrapper">';  
$form['field_text_for_test']['#suffix']='</div>';


if(isset($form_state['values']['field_my_weight_select'])){		
      $content_type = $form_state['values']['field_my_weight_select'][LANGUAGE_NONE][0]['value'];
	  $form["field_text_for_test"][LANGUAGE_NONE][0]['value']['#value']=$content_type;
    }
	else{ $form["field_text_for_test"][LANGUAGE_NONE][0]['value']['#value']=1;}
}
}

function custom_test_entity_callback($form, $form_state){
  return $form['field_text_for_test'];
}


Could you tell me what is the issue in my code??

Thank you

Comments