My submit function for the node form doesn't execute 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(&amp;$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(&amp;$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 ?
In node forms the submit callbacks from #submit are not executed. Instead, there are executed submit from #submit property of submit form element.
You should add the submit in this way:

$form['actions'][$action]['#submit'][] = 'yrv_event_trainer_submit';


Here is an example too.