Add another button removes the default values from my fields on node form I have a node form on which two fields are displaying.
One is a list of radio buttons which is required field.

I am getting a value from url using arg(3) and setting the default value of that field

$form['field_test'][LANGUAGE_NONE]['#default_value'] = arg(3);


I have a link field which is a multi valued field. It means this field as add another button.

When I click on this add another button and then submit the form, I see an error of Test field is required, and that default value of test field gone.

Without clicking the add another button everything works fine.

How can I set a default value of the test field in this case?

Code:

if (!$form['nid']['#value']) {
  if (arg(3)) {
    // Select the default value.
    $tg = arg(3);
    $form['field_test'][LANGUAGE_NONE]['#default_value'] = $tg;
  }
}

  // Make the field readonly.
  $form['field_test'][LANGUAGE_NONE]['#attributes']['disabled'] = 'disabled';
Ok. I found the solution. Let me share my code here.

I stored the argument in the $form_state['storage] so that it can be preserved during the ajax call.

if (arg(0) == 'node' &amp;&amp; arg(3)) {
    $form_state['storage']['field_test_value'] = arg(3);
}

// Only on node creation.
if (!$form['nid']['#value'] &amp;&amp; isset($form_state['storage'])) {
    $form['field_test'][LANGUAGE_NONE]['#default_value'] = $form_state['storage']['field_test_value'];
}

$form['field_test'][LANGUAGE_NONE]['#attributes']['disabled'] = 'disabled';


Hope this will help someone.