How do I implement hook_form_alter() in a module? I am trying to alter a form for the Question content type, whose ID is node-question-form.
I set up a module and tried to implement hook_FORM_ID_alter(), but it's not invoked. Even the simplest implementation as the following is not working.
function constellator_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  echo &quot;alter the form&quot;;
  exit;
}

I have been stuck with this since this morning. Nothing is working for me.
Here is a working example I have pulled from a project and altered to have your module name.

Add this at the top of your .module file:

use Drupal\Core\Form\FormStateInterface;


Then copy this in

/**
 * Implements hook_form_alter().
 */
function constellator_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {

  // Adding custom validation for the welcome page type field.
  if ($form_id == 'node_article_edit_form' || $form_id == 'node_article_form') {
    // Do some stuff.
  }
}


I think most likely what you aren't doing is clearing the Drupal cache to register the hook.  You can click on "clear all caches".  Or better yet, install the drush command line utility and use "drush cr".