From 2dbf445edd525753b534038b760141a49cd95a66 Mon Sep 17 00:00:00 2001 From: Mike Decker Date: Thu, 3 Oct 2024 12:34:01 -0700 Subject: [PATCH] SUL-637: Improve basic page node form --- .../modules/sul_helper/sul_helper.module | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/docroot/profiles/lagunita/sul_profile/modules/sul_helper/sul_helper.module b/docroot/profiles/lagunita/sul_profile/modules/sul_helper/sul_helper.module index 784faef8..6a63a5b2 100644 --- a/docroot/profiles/lagunita/sul_profile/modules/sul_helper/sul_helper.module +++ b/docroot/profiles/lagunita/sul_profile/modules/sul_helper/sul_helper.module @@ -137,11 +137,16 @@ function sul_helper_form_node_form_alter(&$form, FormStateInterface $form_state, if (!$node->hasField('layout_selection')) { return; } + if ($node->bundle() == 'stanford_page') { + // Need to handle the basic page differently due to stanford_profile_helper + // hooks moving things around. + $form["#process"][] = '_sul_helper_basic_page_node_form_process'; + } $form["#process"][] = '_sul_helper_node_form_process'; } /** - * Process callback to adjust node form rendreing. + * Process callback to adjust node form rendering. * * @param array $form * Complete form. @@ -159,3 +164,29 @@ function _sul_helper_node_form_process(array $form, FormStateInterface &$form_st } return $form; } + +/** + * Process callback to adjust node form rendering. + * + * @param array $form + * Complete form. + * @param \Drupal\Core\Form\FormStateInterface $form_state + * Current form state. + * + * @return array + * Modified form. + */ +function _sul_helper_basic_page_node_form_process(array $form, FormStateInterface &$form_state) { + $form['layout_selection']['rel_links'] = [ + '#type' => 'container', + 'sul_rel_links' => $form['sul_rel_links'], + 'sul_rel_links_heading' => $form['sul_rel_links_heading'], + '#states' => [ + 'visible' => [ + ':input[name="layout_selection"]' => ['value' => 'sul_side_nav'], + ] + ] + ]; + unset($form['sul_rel_links'], $form['sul_rel_links_heading']); + return $form; +}