From 9c0bee387734b8441c2aedac830896602240f279 Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Sat, 31 Aug 2013 23:34:37 -0400 Subject: [PATCH] adding show instance to the create form if it's already set. --- .../application/forms/EditHistoryItem.php | 16 +++++++++++----- .../application/services/HistoryService.php | 11 ++++++++++- .../views/scripts/form/edit-history-item.phtml | 5 +++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/airtime_mvc/application/forms/EditHistoryItem.php b/airtime_mvc/application/forms/EditHistoryItem.php index 9552b1c22..16ba5ded5 100644 --- a/airtime_mvc/application/forms/EditHistoryItem.php +++ b/airtime_mvc/application/forms/EditHistoryItem.php @@ -12,7 +12,7 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory 'PrepareElements', array('ViewScript', array('viewScript' => 'form/edit-history-item.phtml')) )); - + /* $instance = new Zend_Form_Element_Select("instance_id"); $instance->setLabel(_("Choose Show Instance")); @@ -51,10 +51,16 @@ class Application_Form_EditHistoryItem extends Application_Form_EditHistory parent::createFromTemplate($template, $required); } - - public function populateShowInstances($possibleInstances) { - - $instance = $this->getElement("instance_id"); + + public function populateShowInstances($possibleInstances, $default) { + + $possibleInstances["0"] = _("No Show"); + + $instance = new Zend_Form_Element_Select("his_instance_select"); + //$instance->setLabel(_("Choose Show Instance")); $instance->setMultiOptions($possibleInstances); + $instance->setValue($default); + $instance->setDecorators(array('ViewHelper')); + $this->addElement($instance); } } \ No newline at end of file diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php index 1001e01cf..08649097f 100644 --- a/airtime_mvc/application/services/HistoryService.php +++ b/airtime_mvc/application/services/HistoryService.php @@ -564,7 +564,16 @@ class Application_Service_HistoryService $formValues = array(); $historyRecord = CcPlayoutHistoryQuery::create()->findPk($id, $this->con); - $file = $historyRecord->getCcFiles(); + $file = $historyRecord->getCcFiles($this->con); + $instance = $historyRecord->getCcShowInstances($this->con); + + if (isset($instance)) { + $show = $instance->getCcShow($this->con); + $selOpts = array(); + $instance_id = $instance->getDbId(); + $selOpts[$instance_id] = $show->getDbName(); + $form->populateShowInstances($selOpts, $instance_id); + } if (isset($file)) { $f = Application_Model_StoredFile::createWithFile($file, $this->con); diff --git a/airtime_mvc/application/views/scripts/form/edit-history-item.phtml b/airtime_mvc/application/views/scripts/form/edit-history-item.phtml index c6cd18466..460d46242 100644 --- a/airtime_mvc/application/views/scripts/form/edit-history-item.phtml +++ b/airtime_mvc/application/views/scripts/form/edit-history-item.phtml @@ -45,9 +45,14 @@
+ getElement("his_instance_select"); ?> + + + +