Skip to content

Instantly share code, notes, and snippets.

@phreaknerd
Last active December 7, 2017 15:23
Show Gist options
  • Save phreaknerd/bdd505c0b23f650953fe14c463b56f03 to your computer and use it in GitHub Desktop.
Save phreaknerd/bdd505c0b23f650953fe14c463b56f03 to your computer and use it in GitHub Desktop.
Drupal 8 reorder module-priority in form_alter to get the menu into $form.
/**
* Implements hook_form_FORM_ID_alter()
*/
function mymodule_form_node_page_edit_form_alter(&$form, FormStateInterface $form_state) {
kint($form); //Now $form['menu'] is present.
}
/**
* Implements hook_module_implements_alter()
*/
function mymodule_module_implements_alter(&$implementations, $hook) {
if($hook == 'form_alter' && isset($implementations['mymodule'])) {
//Move mymodule to the end otherwise $form['menu'] is missing in mymodule_form_node_page_edit_form_alter()
$group = $implementations['alingsas_context'];
unset($implementations['alingsas_context']);
$implementations['alingsas_context'] = $group;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment