From 64fd166b61c5ddfe87cbaaf2cbaee44a94c94cd5 Mon Sep 17 00:00:00 2001
From: Eric Bremner <ebremner@uwaterloo.ca>
Date: Thu, 6 Apr 2023 09:21:17 -0400
Subject: [PATCH] ISTWCMS-5551: adding code to remove comments from regular
 days service hours

---
 uw_ct_service.module | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/uw_ct_service.module b/uw_ct_service.module
index f861674..5e32e76 100644
--- a/uw_ct_service.module
+++ b/uw_ct_service.module
@@ -95,6 +95,17 @@ function _uw_ct_service_get_location_options(): array {
  * Implements hook_form_FORM_ID_alter().
  */
 function uw_ct_service_form_node_uw_ct_service_form_alter(array &$form, FormStateInterface $form_state, string $form_id): void {
+
+  // Unset the table header for comments in the regular days.
+  unset($form['field_uw_service_hours']['widget']['office_hours']['value']['#header']['comment']);
+
+  // Step through each of the regular days and remove the comments.
+  foreach ($form['field_uw_service_hours']['widget']['office_hours']['value'] as $index => $value) {
+    if (is_int($index)) {
+      $form['field_uw_service_hours']['widget']['office_hours']['value'][$index]['#field_settings']['comment'] = 0;
+    }
+  }
+
   // Add locations pre-fill menu.
   $form['group_service_location']['location_presets_select'] = [
     '#title' => t('Location lookup'),
-- 
GitLab