How do I pull a field value from a form field in to my inline entity form? I'm trying to do something which I would think is fairly simple, but I'm just stumped right now, hoping somebody can help.

I have an entity called 'page', and in that entity I have inline entities called 'subpages'. Both of these entities have a field called 'group_reference' which tells the entity what 'group' the entities belong to.

Basically what I want to do is automatically change the group_reference form field value in my inline entity form to match the group reference in my page form. So far, I'm using inline_entity_form_entity_form_alter to access the inline entity forms values. I'm able to adjust the value to an arbitrary value like this:

function MYMODULE_inline_entity_form_entity_form_alter(&amp;$entity_form, &amp;$form_state) {
  if ($entity_form['#bundle'] == 'subpage') {
    $entity_form['field_group_reference']['und']['0']['#default_value']=X;
  }
}


X being the group id.

So the next step I want is to pull in the group id from the page group_reference field which is already set. That way, they will always match (the user is not able to change this value, it all should be done behind the scenes).

I've tried to include in my module a function that pulls out the value from the field, but I just can't seem to make it work:

function MYMODULE_grab_group_reference(&amp;$form, &amp;$form_state) {
    return $form['field_group_reference']['und']['#value'];
}

function MYMODULE_inline_entity_form_entity_form_alter(&amp;$entity_form, &amp;$form_state) {
  if ($entity_form['#bundle'] == 'subpage') {
    $groupid=MYMODULE_grab_group_reference();
    $entity_form['field_group_reference']['und']['0']['#default_value']=$groupid;
  }
}


I've tried a bunch of different variations. Am I not targeting my values correctly? Is this just an improper way to do it? I'm flummoxed. Any help would be greatly appreciated! Thanks!
Just want to share my solution to this problem. Turns out I didn't need another function, I had all the variables available in my MYMODULE_inline_entity_form_entity_form_alter function in the $form_state array.

I targeted: $form_state['input']['field_group_reference'][und]

And that got me the value of the field in my parent entity.