From 052bfa0f2597cb40b35cfabbe86ef0a7c018660d Mon Sep 17 00:00:00 2001 From: Jagadedes Date: Fri, 17 Oct 2014 16:11:58 +0530 Subject: [PATCH] 29767 save and preview widget --- CRM/Wci/Form/CreateWidget.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CRM/Wci/Form/CreateWidget.php b/CRM/Wci/Form/CreateWidget.php index 9eaccd5..ca7a448 100644 --- a/CRM/Wci/Form/CreateWidget.php +++ b/CRM/Wci/Form/CreateWidget.php @@ -144,7 +144,7 @@ class CRM_Wci_Form_CreateWidget extends CRM_Core_Form { 'isDefault' => TRUE, ), array( - 'type' => 'savenprev', + 'type' => 'next', 'name' => ts('Save & Preview'), ), )); @@ -256,6 +256,7 @@ $('#widgetwci').html(wciwidgetcode); $equals = " = "; $quote = "'"; } + if (isset($this->_id)) { $sql = "UPDATE civicrm_wci_widget SET title = '". $values['title'] . "', logo_image = '" . $values['logo_image'] . "', image = '" @@ -300,15 +301,21 @@ $('#widgetwci').html(wciwidgetcode); try { $transaction = new CRM_Core_Transaction(); CRM_Core_DAO::executeQuery($sql); - $transaction->commit(); + + if(isset($_REQUEST['_qf_CreateWidget_next'])) { + $widget_id = CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()'); + CRM_Utils_System::redirect('civicrm/wci/widget?action=update&reset=1&id=' . $widget_id); + } else { + CRM_Utils_System::redirect('civicrm/wci/widget?reset=1'); + } } catch (Exception $e) { //TODO print_r($e->getMessage()); $transaction->rollback(); } - + parent::postProcess(); } -- 2.25.1