how to add an event subscriber when the user reaches the login form I am new on Drupal 8 , I have implemented a hook 'hook_form_alter' in my module to add a new field to the login form , but now I want to handle it with the event , I want to trigger an event when the user reaches the login form and then add this field using event not a hook.
Can anyone please suggest me how to do it ?
This is the hook
function my_module_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == 'user_login_form' ) {
    // Add placeholders.
    $form['condition'] = array(
      '#type' =&gt; 'checkbox',
      '#options' =&gt; t('Enable'),
      '#title' =&gt; t('J’accepte les conditions'),
      '#required' =&gt; true,
    );
  }
}
You can't, not with core alone. D8 doesn't have a form-alter event.
D8 added events as an alternative to some D7 hooks but didn't fully replace all the hooks available. Replacing all hooks was mooted for a D10 goal but didn't make the cut.
As such, the only way to do this modify core functionality like:

Patch core (see issue comment) to add form-alter events.
Do something like Hook Event Dispatcher which wraps custom form-alter events around a hook_form_alter handler.

Then add an event subscriber for it.