better casting on form checkbox, setting populate flag properly based on if id is set (for create/update)
This commit is contained in:
parent
31c604d09c
commit
aaf2e5c2f6
|
@ -157,7 +157,9 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
Logging::info($params);
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$historyService->createPlayedItem($params);
|
||||
$json = $historyService->createPlayedItem($params);
|
||||
|
||||
$this->_helper->json->sendJson($json);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
|
@ -168,9 +170,12 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
public function editListItemAction()
|
||||
{
|
||||
$id = $this->_getParam('id', null);
|
||||
Logging::info("Id is: $id");
|
||||
|
||||
$populate = isset($id) ? true : false;
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$form = $historyService->makeHistoryItemForm($id, true);
|
||||
$form = $historyService->makeHistoryItemForm($id, $populate);
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->view->dialog = $this->view->render('playouthistory/dialog.phtml');
|
||||
|
@ -188,14 +193,20 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
|
||||
public function updateListItemAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
Logging::info($params);
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$json = $historyService->editPlayedItem($params);
|
||||
|
||||
$this->view->data = $json;
|
||||
try {
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
Logging::info($params);
|
||||
|
||||
$historyService = new Application_Service_HistoryService();
|
||||
$json = $historyService->editPlayedItem($params);
|
||||
|
||||
$this->_helper->json->sendJson($json);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
Logging::info($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAggregateItemAction()
|
||||
|
@ -207,7 +218,7 @@ class PlayouthistoryController extends Zend_Controller_Action
|
|||
$historyService = new Application_Service_HistoryService();
|
||||
$json = $historyService->editPlayedFile($params);
|
||||
|
||||
$this->view->data = $json;
|
||||
$this->_helper->json->sendJson($json);
|
||||
}
|
||||
|
||||
public function templateAction()
|
||||
|
|
|
@ -13,6 +13,7 @@ class Application_Form_EditHistoryItem extends Zend_Form
|
|||
|
||||
const ITEM_TYPE = "type";
|
||||
const ITEM_CLASS = "class";
|
||||
const ITEM_OPTIONS = "options";
|
||||
const ITEM_ID_SUFFIX = "name";
|
||||
|
||||
const TEXT_INPUT_CLASS = "input_text";
|
||||
|
@ -80,8 +81,13 @@ class Application_Form_EditHistoryItem extends Zend_Form
|
|||
),
|
||||
TEMPLATE_BOOLEAN => array(
|
||||
"class" => "Zend_Form_Element_Checkbox",
|
||||
"filters" => array(
|
||||
"Boolean"
|
||||
"validators" => array(
|
||||
array(
|
||||
"class" => "Zend_Validate_InArray",
|
||||
"options" => array(
|
||||
"haystack" => array(0,1)
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
TEMPLATE_INT => array(
|
||||
|
@ -93,9 +99,6 @@ class Application_Form_EditHistoryItem extends Zend_Form
|
|||
),
|
||||
"attrs" => array(
|
||||
"class" => self::TEXT_INPUT_CLASS
|
||||
),
|
||||
"filters" => array(
|
||||
"Int"
|
||||
)
|
||||
),
|
||||
TEMPLATE_FLOAT => array(
|
||||
|
@ -198,7 +201,7 @@ class Application_Form_EditHistoryItem extends Zend_Form
|
|||
|
||||
if (isset($formElType["attrs"])) {
|
||||
|
||||
$attrs = $formElType["filters"];
|
||||
$attrs = $formElType["attrs"];
|
||||
|
||||
foreach ($attrs as $key => $value) {
|
||||
$el->setAttrib($key, $value);
|
||||
|
@ -219,7 +222,8 @@ class Application_Form_EditHistoryItem extends Zend_Form
|
|||
$validators = $formElType["validators"];
|
||||
|
||||
foreach ($validators as $index => $arr) {
|
||||
$validator = new $arr[self::ITEM_CLASS]();
|
||||
$options = isset($arr[self::ITEM_OPTIONS]) ? $arr[self::ITEM_OPTIONS] : null;
|
||||
$validator = new $arr[self::ITEM_CLASS]($options);
|
||||
|
||||
//extra validator info
|
||||
if (isset($arr["params"])) {
|
||||
|
|
|
@ -635,6 +635,7 @@ class Application_Service_HistoryService
|
|||
try {
|
||||
$form = $this->makeHistoryItemForm(null);
|
||||
$history_id = $form->getElement("his_item_id");
|
||||
$json = array();
|
||||
|
||||
if ($form->isValid($data)) {
|
||||
$history_id->setIgnore(true);
|
||||
|
@ -647,8 +648,14 @@ class Application_Service_HistoryService
|
|||
}
|
||||
else {
|
||||
Logging::info("created list item NOT VALID");
|
||||
Logging::info($form->getMessages());
|
||||
|
||||
$msgs = $form->getMessages();
|
||||
Logging::info($msgs);
|
||||
|
||||
$json["error"] = $msgs;
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
throw $e;
|
||||
|
@ -664,6 +671,9 @@ class Application_Service_HistoryService
|
|||
$history_id = $form->getElement("his_item_id");
|
||||
$history_id->setRequired(true);
|
||||
|
||||
Logging::info($data);
|
||||
$json = array();
|
||||
|
||||
if ($form->isValid($data)) {
|
||||
$history_id->setIgnore(true);
|
||||
$values = $form->getValues();
|
||||
|
@ -675,12 +685,17 @@ class Application_Service_HistoryService
|
|||
}
|
||||
else {
|
||||
Logging::info("edited list item NOT VALID");
|
||||
|
||||
$msgs = $form->getMessages();
|
||||
Logging::info($msgs);
|
||||
|
||||
$json["error"] = $msgs;
|
||||
}
|
||||
|
||||
Logging::info($form->getMessages());
|
||||
|
||||
return $json;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -379,8 +379,8 @@ var AIRTIME = (function(AIRTIME) {
|
|||
$.post(url, data, function(json) {
|
||||
|
||||
//TODO put errors on form.
|
||||
if (json.data !== "true") {
|
||||
//makeHistoryDialog(json.dialog);
|
||||
if (json.error !== undefined) {
|
||||
|
||||
}
|
||||
else {
|
||||
removeHistoryDialog();
|
||||
|
|
Loading…
Reference in New Issue