From c9bf8b5fe4b5f8538ef2f83a880182b7ec595e6d Mon Sep 17 00:00:00 2001 From: Eric Bremner <ebremner@uwaterloo.ca> Date: Fri, 14 Oct 2022 10:00:26 -0400 Subject: [PATCH] ISTWCMS-5880: coding standards --- uw_cfg_common.module | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/uw_cfg_common.module b/uw_cfg_common.module index 0772ca8d..4843c0f7 100644 --- a/uw_cfg_common.module +++ b/uw_cfg_common.module @@ -886,11 +886,25 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state, } } + $node = \Drupal::routeMatch()->getParameter('node'); + // If there is a type of media field, it means that we are // on a node add/edit page, so add the states for the // actual media types in the hero section. if (isset($form['field_uw_type_of_media'])) { + $node_type = str_replace('node_uw_ct_', '' , $form_id); + $node_type = str_replace('_edit', '' , $node_type); + $node_type = str_replace('_form', '' , $node_type); + + $remove_hero_image_nodes = [ + 'web_page', + ]; + + if (in_array($node_type, $remove_hero_image_nodes)) { + unset($form['field_uw_type_of_media']['widget']['#options']['image']); + } + // Set the states for the hero image. $form['field_uw_hero_image']['#states'] = [ 'visible' => [ @@ -1452,7 +1466,8 @@ function uw_cfg_common_preprocess_html(&$variables): void { */ function _uw_cfg_common_allowed_media_types( FieldStorageConfig $definition, - ContentEntityInterface $entity = NULL, $cacheable + ContentEntityInterface $entity = NULL, + $cacheable ) { return [ -- GitLab