Skip to content

Commit

Permalink
feat(shs-5567): add widget hook preprocessor to hide and disable menu…
Browse files Browse the repository at this point in the history
… link checkbox
  • Loading branch information
hectorlj committed Apr 2, 2024
1 parent 6476dc7 commit 13fd031
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docroot/modules/humsci/hs_admin/hs_admin.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Render\Markup;
use Drupal\user\Entity\User;
use Drupal\user\UserInterface;

/**
* Implements hook_preprocess_node_edit_form().
Expand Down Expand Up @@ -200,3 +200,19 @@ function hs_admin_field_widget_complete_paragraphs_browser_form_alter(&$field_wi
}
}
}

/**
* Implements hook_field_widget_complete_WIDGET_TYPE_form_alter().
*/
function hs_admin_field_widget_complete_menu_link_default_form_alter(array &$field_widget_complete_form, FormStateInterface $form_state, array $context) {
// Go through each widget element.
foreach (Element::children($field_widget_complete_form['widget']) as $key) {
if (!is_int($key) || !($field_widget_complete_form['widget'][$key]['expanded'] ?? FALSE)) {
continue;
} else {
// Disable access to `expanded` checbox.
$field_widget_complete_form['widget'][$key]['expanded']['#access'] = FALSE;
break;
}
}
}

0 comments on commit 13fd031

Please sign in to comment.