diff --git a/airtime_mvc/application/forms/EditHistory.php b/airtime_mvc/application/forms/EditHistory.php index 5c61a1125..ad7ae7a05 100644 --- a/airtime_mvc/application/forms/EditHistory.php +++ b/airtime_mvc/application/forms/EditHistory.php @@ -113,35 +113,35 @@ class Application_Form_EditHistory extends Zend_Form ); public function init() { - - $history_id = new Zend_Form_Element_Hidden($this::ID_PREFIX.'id'); - $history_id->setValidators(array( - new Zend_Validate_Int() - )); - $history_id->setDecorators(array('ViewHelper')); + + $history_id = new Zend_Form_Element_Hidden($this::ID_PREFIX.'id'); + $history_id->setValidators(array( + new Zend_Validate_Int() + )); + $history_id->setDecorators(array('ViewHelper')); $this->addElement($history_id); - $dynamic_attrs = new Zend_Form_SubForm(); - $this->addSubForm($dynamic_attrs, $this::ID_PREFIX.'template'); - - // Add the submit button - $this->addElement('button', $this::ID_PREFIX.'save', array( - 'ignore' => true, - 'class' => 'btn '.$this::ID_PREFIX.'save', - 'label' => _('Save'), - 'decorators' => array( - 'ViewHelper' - ) - )); - - // Add the cancel button - $this->addElement('button', $this::ID_PREFIX.'cancel', array( - 'ignore' => true, - 'class' => 'btn '.$this::ID_PREFIX.'cancel', - 'label' => _('Cancel'), - 'decorators' => array( - 'ViewHelper' - ) + $dynamic_attrs = new Zend_Form_SubForm(); + $this->addSubForm($dynamic_attrs, $this::ID_PREFIX.'template'); + + // Add the submit button + $this->addElement('button', $this::ID_PREFIX.'save', array( + 'ignore' => true, + 'class' => 'btn '.$this::ID_PREFIX.'save', + 'label' => _('Save'), + 'decorators' => array( + 'ViewHelper' + ) + )); + + // Add the cancel button + $this->addElement('button', $this::ID_PREFIX.'cancel', array( + 'ignore' => true, + 'class' => 'btn '.$this::ID_PREFIX.'cancel', + 'label' => _('Cancel'), + 'decorators' => array( + 'ViewHelper' + ) )); } diff --git a/airtime_mvc/application/forms/EditHistoryFile.php b/airtime_mvc/application/forms/EditHistoryFile.php index 22bf1f24d..b58db19a1 100644 --- a/airtime_mvc/application/forms/EditHistoryFile.php +++ b/airtime_mvc/application/forms/EditHistoryFile.php @@ -15,8 +15,8 @@ class Application_Form_EditHistoryFile extends Application_Form_EditHistory ); } - public function createFromTemplate($template, $required) { - - parent::createFromTemplate($template, $required); + public function createFromTemplate($template, $required) { + + parent::createFromTemplate($template, $required); } } \ No newline at end of file diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php index 6ddd136f6..099f3c903 100644 --- a/airtime_mvc/application/services/HistoryService.php +++ b/airtime_mvc/application/services/HistoryService.php @@ -525,22 +525,22 @@ class Application_Service_HistoryService $md = $file->getDbColMetadata(); $prefix = Application_Form_EditHistoryFile::ID_PREFIX; - $formValues = array(); - $formValues["{$prefix}id"] = $id; - - foreach($template["fields"] as $index => $field) { - + $formValues = array(); + $formValues["{$prefix}id"] = $id; + + foreach($template["fields"] as $index => $field) { + $key = $field["name"]; if (in_array($key, $required)) { continue; } - - $value = $md[$key]; - $formValues["$prefix{$key}"] = $value; - } - - $form->populate($formValues); + + $value = $md[$key]; + $formValues["$prefix{$key}"] = $value; + } + + $form->populate($formValues); return $form; } @@ -563,7 +563,7 @@ class Application_Service_HistoryService $templateValues = $values[$prefix."template"]; $md = array(); - + foreach ($templateValues as $index => $value) { $key = substr($index, $prefix_len); @@ -746,25 +746,25 @@ class Application_Service_HistoryService try { $id = $data["his_file_id"]; $form = $form = $this->makeHistoryFileForm($id); - $history_id = $form->getElement("his_file_id"); + $history_id = $form->getElement("his_file_id"); $history_id->setRequired(true); Logging::info($data); $json = array(); if ($form->isValid($data)) { - $history_id->setIgnore(true); + $history_id->setIgnore(true); $values = $form->getValues(); - Logging::info("edited list item"); - Logging::info($values); - + Logging::info("edited list item"); + Logging::info($values); + $this->populateTemplateFile($values, $id); } else { - $msgs = $form->getMessages(); - Logging::info($msgs); - + $msgs = $form->getMessages(); + Logging::info($msgs); + $json["error"] = $msgs; }