How to set default value for textfield programmatically in drupal 7? I need a form_alter code or something that I could use to set my field value. I'm getting the value from the parameter and I've tried a lot of ways but nothing works for me. This is the list of codes I've tried on my custom module:

function custommodule_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form['#node']-&gt;type == 'custom_package') {
      $default = $_GET['field_product_add_ons'];
      $form["field_add_on_nids"][LANGUAGE_NONE][0]['value']['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE][0]['value']['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE][0]['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE]['#default_value'] = $default;

  }


  if($form_id == 'custom_package') {
      $default = $_GET['field_product_add_ons'];
      $form["field_add_on_nids"][LANGUAGE_NONE][0]['value']['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE][0]['value']['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE][0]['#default_value'] = $default;
      $form['field_add_on_nids'][LANGUAGE_NONE]['#default_value'] = $default;

  }
}


I think the code will be simple but the field is still blank. My field is just a single text field.

Thank you in advance for your help!
Try 

 $form['field_add_on_nids']['und']['#default_value'] = $default;


Thanks