D8 Custom submit handler does not appear to be being called

by gibbo   Last Updated May 15, 2019 17:07 PM - source

Can anyone tell me why my custom handler is not being called when I save a new entity please, Im using D8.7


use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\HttpFoundation\Request;

function testmodule_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  foreach (array_keys($form['tasks']) as $action) {
    if ($action != 'preview' && isset($form['tasks'][$action]['#type']) && $form['tasks'][$action]['#type'] === 'submit') {
      $form['tasks'][$action]['#submit'][] = 'testmodule_form_submit';

function testmodule_form_submit(array $form, FormStateInterface $form_state){
    drupal_set_message("Why won't this message show?");
Tags : hooks

Related Questions

How to find hooks being called by a Drupal page?

Updated April 03, 2015 21:20 PM

Modify text of error message for required field

Updated April 22, 2015 20:03 PM

Where are hooks stored/cached?

Updated April 13, 2015 20:03 PM