diff --git a/docroot/modules/custom/va_gov_home/src/EventSubscriber/FormEventSubscriber.php b/docroot/modules/custom/va_gov_home/src/EventSubscriber/FormEventSubscriber.php index 3ec9e72d969..28b29bbc611 100644 --- a/docroot/modules/custom/va_gov_home/src/EventSubscriber/FormEventSubscriber.php +++ b/docroot/modules/custom/va_gov_home/src/EventSubscriber/FormEventSubscriber.php @@ -2,6 +2,7 @@ namespace Drupal\va_gov_home\EventSubscriber; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\core_event_dispatcher\Event\Form\FormAlterEvent; use Drupal\core_event_dispatcher\FormHookEvents; use Drupal\va_gov_user\Service\UserPermsService; @@ -11,6 +12,7 @@ * VA.gov home event subscriber. */ class FormEventSubscriber implements EventSubscriberInterface { + use StringTranslationTrait; /** * The VA user permission service. @@ -29,18 +31,30 @@ public function __construct(UserPermsService $permsService) { $this->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) { + public function formAlter(FormAlterEvent $event): void { + $form = &$event->getForm(); if ($event->getFormId() === 'menu_link_content_home-page-hub-list_form') { - $form = &$event->getForm(); $admin = $this->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, $admin); + } } /** @@ -51,7 +65,7 @@ public function formAlter(FormAlterEvent $event) { * @param bool $admin * TRUE if current user is an admin. */ - public function hubMenuFormAlter(array &$form, bool $admin) { + public function hubMenuFormAlter(array &$form, bool $admin): void { $this->hubMenuHideAddtributes($form) ->hubMenuHideExpanded($form) ->hubMenuHideViewMode($form, $admin) @@ -123,12 +137,13 @@ public function hubMenuHideParentLink(array &$form, bool $admin): static { } /** - * {@inheritdoc} + * Hides the description field on certain menu link forms. + * + * @param array $form + * The form element array. */ - public static function getSubscribedEvents(): array { - return [ - FormHookEvents::FORM_ALTER => ['formAlter'], - ]; + public function hideMenuLinkDescriptionField(array &$form): void { + $form['description']['#access'] = FALSE; } }