I'm using the module EntityForm to build a form. This EntityForm will be an entity reference field in the content type ShowForm. ShowForm contains the form and some other fields that give some information about what the form will be used for. Once the EntityForm is filled in, they should be redirected to the ShowForm-node that contained it so they can fill it in again (for someone else). There will be different ShowForm-nodes that all have a reference to this EntityForm, but I have to redirect them to the specific ShowForm-node they filled in the form on.
I've added an extra submit button and submit handler that submits the form and redirects them to a ShowForm-node so they can fill it in once more. The problem is that I can't find a way to redirect them to a ShowForm-node without hardcoding the id (so it's only useable for 1 ShowForm-node).
For example:
$form_state['redirect']='node/123'
where 123 is the nodeid of the node showing the EntityForm. I'd like to be able to get the nodeid dynamically for redirecting instead of manually putting in '123'.
This is my code so far:
function extra_inschrijving_form_alter(&$form, &$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';
}
}
function extra_inschrijving_default_wp_submit($form, &$form_state){
//Do some stuff
$node_id=???
$form_state['redirect']='node/' . $node_id;
}
Is there a way to get the right value for this $node_id? Is it possible?
(I was thinking about adding a hidden field to the EntityForm and using rules to set it with the nodeid of ShowForm when a ShowForm-node is created, but I can't seem to acces the EntityForm's fields in rules even when I use "has field"-conditions)