From ba1752ebc66ffa8bc29c640e3ffcb0ee5237dc33 Mon Sep 17 00:00:00 2001 From: MorganDawe Date: Mon, 17 Oct 2016 10:38:53 -0300 Subject: [PATCH] Added context info to ingest forms. --- includes/ingest.form.inc | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/includes/ingest.form.inc b/includes/ingest.form.inc index 7fd95f9b..c9f070e2 100644 --- a/includes/ingest.form.inc +++ b/includes/ingest.form.inc @@ -921,6 +921,36 @@ function islandora_ingest_form_get_steps(array &$form_state) { return $steps; } +/** + * Implements hook_form_alter(). + */ +function islandora_form_islandora_ingest_form_alter(&$form, &$form_state) { + // Check if multiple content models are available to select from. + if (count($form_state['islandora']['step_storage']['islandora_basic_collection_select_content_model']['models']) > 1) { + if (!isset($form_state['islandora']['step_storage']['active_cmodel']) && + isset($form_state['islandora']['step_storage']['islandora_basic_collection_select_content_model']['values'])) { + $model = $form_state['islandora']['step_storage']['islandora_basic_collection_select_content_model']['values']['models']; + $form_state['islandora']['step_storage']['active_cmodel'] = islandora_object_load($model); + } + } + else { + // Keep a reference to the only available cmodel, if it does not + // already exist. + if (!isset($form_state['islandora']['step_storage']['active_cmodel'])) { + $model = $form_state['islandora']['step_storage']['islandora_basic_collection_select_content_model']['models'][0]; + $form_state['islandora']['step_storage']['active_cmodel'] = islandora_object_load($model); + } + } + + if (isset($form_state['islandora']['step_storage']['active_cmodel'])) { + $label = $form_state['islandora']['step_storage']['active_cmodel']->{'label'}; + $form['contact_information'] = array( + '#markup' => "

$label

", + '#weight' => -1000, + ); + } +} + /** * Filter the ingest steps to only steps of type 'form'. *