diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index dfc41445259..cd149d56c1d 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -253,6 +253,7 @@ module: va_gov_github: 0 va_gov_govdelivery: 0 va_gov_graphql: 0 + va_gov_header_footer: 0 va_gov_help_center: 0 va_gov_links: 0 va_gov_live_field_migration: 0 diff --git a/docroot/modules/custom/va_gov_header_footer/src/EventSubscriber/FormEventSubscriber.php b/docroot/modules/custom/va_gov_header_footer/src/EventSubscriber/FormEventSubscriber.php new file mode 100644 index 00000000000..d7148cf4031 --- /dev/null +++ b/docroot/modules/custom/va_gov_header_footer/src/EventSubscriber/FormEventSubscriber.php @@ -0,0 +1,69 @@ +permsService = $permsService; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents(): array { + return [ + FormHookEvents::FORM_ALTER => ['formAlter'], + ]; + } + + /** + * Form alters for va_gov_home. + * + * @param \Drupal\core_event_dispatcher\Event\Form\FormAlterEvent $event + * The form event. + */ + public function formAlter(FormAlterEvent $event): void { + $form = &$event->getForm(); + $formId = $event->getFormId(); + $admin = $this->permsService->hasAdminRole(TRUE); + if (in_array($formId, $this->menus) && !$admin) { + $this->hideMenuLinkDescriptionField($form); + } + } + +} diff --git a/docroot/modules/custom/va_gov_header_footer/src/Traits/MenuFormAlter.php b/docroot/modules/custom/va_gov_header_footer/src/Traits/MenuFormAlter.php new file mode 100644 index 00000000000..2f27229e093 --- /dev/null +++ b/docroot/modules/custom/va_gov_header_footer/src/Traits/MenuFormAlter.php @@ -0,0 +1,20 @@ +permsService->hasAdminRole(TRUE); $this->hubMenuFormAlter($form, $admin); } - if ($event->getFormId() === 'menu_link_content_va-gov-footer_form' || $event->getFormId() === 'menu_link_content_footer-bottom-rail_form') { - $this->hideMenuLinkDescriptionField($form); - } } /** @@ -125,16 +122,6 @@ public function hubMenuHideParentLink(array &$form, bool $admin): static { return $this; } - /** - * Hides the description field on certain menu link forms. - * - * @param array $form - * The form element array. - */ - public function hideMenuLinkDescriptionField(array &$form): void { - $form['description']['#access'] = FALSE; - } - /** * {@inheritdoc} */