I need to add my submit function to the node insert/edit form.
Here's my code.
function yrv_event_trainer_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id)
{
if (in_array($form_id, ['node_veranstaltung_edit_form', 'node_veranstaltung_form'])){
// Here we're adding our submit function before standard one.
array_unshift($form['#submit'], 'yrv_event_trainer_submit');
}
}
function yrv_event_trainer_submit(&$form, FormStateInterface $form_state){
// Here's code inside my submit function
}
But when I'm pressing the "Save and publish" button on the form, this submit function doesn't execute.
For example, I can't debug it having set a breakpoint inside the submit function.
But the array $form['#submit'] has my submit function.
Could you clarify me, what can be a reason of the problem ?