I'm trying to add a new validation method for 'user_login_form' using HookEventDispatcher module and events:
class MyFormEventsSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents() { return [ HookEventDispatcherInterface::FORM_ALTER => 'alterForm']; } public function alterForm(FormAlterEvent $event) { if ($event->getFormId() == 'user_login_form') { $form = &$event->getForm(); $form['#validate'][] = 'my_api_authentication'; } } function my_api_authentication(&$form, FormStateInterface $form_state) { $test = 1; } }
But i never reach my_api_authentication function. How i need to refer it and where should be suposed to be implemented ?
May be i should manage with hook_form_FORM_ID_alter instead FORM_ALTER HookEventDispatcherInterface event ?