Copying field values from one EntityForm to another on submit I'm using Drupal 7 and the Entityform module to build a form for people to fill in on my website.

This form will be filled in by a parent and contains some data about his child. There will be 2 buttons: 


1 for submitting the form data (default submit button/function) 
1 for submitting the form data + opening a new form (of the same type) for a 2nd child (custom submit button/function). 


Since this 2nd child will have a lot of data (address, last name,...) that's the same as the first child I'd like to already have those fields filled in in the 2nd form (by using field values from the first form). The same can be repeated for a 3rd child, a 4th child,...

This is my code so far: 

function extra_inschrijving_form_alter(&amp;$form, &amp;$form_state, $form_id){

    if ($form_id == 'generiek_inschrijvingsformulier__entityform_edit_form'){
        $form['submit2'] = $form['actions']['submit'];
        $form['submit2']['#value']='Inschrijven en ook een broer inschrijven';
        $form['submit2']['#weight']=100;
        $form['submit2']['#submit'][1]='extra_inschrijving_default_wp_submit';      
    }
}


This code added another submit-button and attached a submit handler (this works).

function extra_inschrijving_default_wp_submit($form, &amp;$form_state){
   $values = &amp;$form_state['values'];

   $prepopulates = array(
      'edit[field_entity_reference][und]' =&gt; 
            $values['field_entity_reference']['und'][0]['target_id'],
      'edit[field_1][und][0][value]' =&gt; $values['field_1']['und'][0]['value'],
      'edit[field_2][und][0][value]' =&gt; $values['field_2']['und'][0]['value'],
   );

   $form_state['redirect'] = array(
     'node/11',
     array(
        'query' =&gt; $prepopulates,
     ),
  );
}


Here I copy some field values from the form that will be submitted into the new form that has to be filled in. The parent should still be able to change the fields if he wants to. 
Both the normal fields and the entity reference field (select list) are copied/prepopulated successfully, but if the parent changes the entity reference field on the new form it still contains the old, prepopulated value when he submits it (although visibly something else is selected in the list).
If you don't mind using query parameter for passing value. Prepopulate would be your choice.

Example code:

function extra_inschrijving_default_wp_submit($form, &amp;$form_state){
  $values = &amp;$form_state['values'];
  $prepopulates = array(
    'edit[title]' =&gt; $values['title'],
  );
  $form_state['redirect'] = array(
    'node/add/article',
    array(
      'query' =&gt; $prepopulates,
    ),
  );
}


$prepopulates is an array for query parameter which will pass the pre-filled values to the node add form. The array keys specify the fields prepopulate to. You can learn how to set the key from the handbook page.

At this moment, the latest stable version 2.1 has a known bug and it is discussing here. If you the module is not working on some field, you may need to add the patch in the thread. I don't recommend the older stable version because 2.1 has fixed an exploit.