How can i find out which form mode is used from hook_form_FORM_ID_alter? I have created a new form mode (in the UI at admin/structure/display-modes) for a custom entity (form mode is entitled apply) and added apply to the form handler classes in the entity class.

The form is built and returned in a Controller, and specifies the form mode.

$form = $this-&gt;entityFormBuilder()-&gt;getForm($entity, 'apply');

Now I would like to be able to determine from a hook_form_alter whether this form is being displayed using the apply form mode, but I cannot work out how that is available from $form or $form_state.
You can try EntityFormInterface::getOperation:

function mymodule_form_FORM_ID_alter(&amp;$form, FormStateInterface $form_state) {
  // only continue if this is for form mode "apply"
  if ($form_state-&gt;getFormObject()-&gt;getOperation() !== 'apply') {
    return;
  }

  // do stuff

}