Skip to content

Commit

Permalink
VACMS-14793: Hide Link Description Field in Footers
Browse files Browse the repository at this point in the history
  • Loading branch information
chri5tia committed Sep 18, 2023
1 parent 47e4984 commit 0806063
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ public function __construct(UserPermsService $permsService) {
* @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);
}
}

/**
Expand All @@ -51,7 +54,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)
Expand Down Expand Up @@ -122,6 +125,16 @@ 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}
*/
Expand Down

0 comments on commit 0806063

Please sign in to comment.