From 26b60facbfba9efeefe6f77f7c6063fb76185561 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Thu, 23 Feb 2012 14:52:50 +0000 Subject: [PATCH] [-] BO : #PSTEST-400 - Fix bug with button "Save and stay" from AdminAttributesGroups --- .../admin/AdminAttributesGroupsController.php | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/controllers/admin/AdminAttributesGroupsController.php b/controllers/admin/AdminAttributesGroupsController.php index c58bc5f22..c9f6eb780 100644 --- a/controllers/admin/AdminAttributesGroupsController.php +++ b/controllers/admin/AdminAttributesGroupsController.php @@ -375,7 +375,15 @@ class AdminAttributesGroupsControllerCore extends AdminController parent::processAdd($token); if (Tools::isSubmit('submitAdd'.$this->table.'AndStay') && !count($this->errors)) - $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&conf=3&update'.$this->table.'&token='.$token; + { + if ($this->display == 'add') + $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&conf=3&update'.$this->table.'&token='.$token; + else + $this->redirect_after = self::$currentIndex.'&id_attribute_group='.(int)Tools::getValue('id_attribute_group').'&'.$this->identifier.'&conf=3&update'.$this->table.'&token='.$token; + } + + if (count($this->errors)) + $this->defineObjectTypeAttribute(); } /** @@ -391,7 +399,7 @@ class AdminAttributesGroupsControllerCore extends AdminController if ($this->display == 'add') $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&conf=3&update'.$this->table.'&token='.$token; else - $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'='.(int)Tools::getValue($this->identifier).'&conf=4&update'.$this->table.'&token='.$token; + $this->redirect_after = self::$currentIndex.'&'.$this->identifier.'=&id_attribute_group='.(int)Tools::getValue('id_attribute_group').'&conf=3&update'.$this->table.'&token='.$token; } } @@ -457,7 +465,8 @@ class AdminAttributesGroupsControllerCore extends AdminController $this->toolbar_btn['save-and-stay'] = array( 'short' => 'SaveAndStay', 'href' => '#', - 'desc' => $this->l('Save and stay'), + 'desc' => $this->l('Save and add'), + 'force_desc' => true, ); $back = self::$currentIndex.'&token='.$this->token; @@ -514,17 +523,25 @@ class AdminAttributesGroupsControllerCore extends AdminController } public function initProcess() + { + $this->defineObjectTypeAttribute(); + + parent::initProcess(); + if ($this->table == 'attribute') + $this->display = 'editAttributes'; + } + + protected function defineObjectTypeAttribute() { if (Tools::getValue('id_attribute') || Tools::isSubmit('deleteattribute') || Tools::isSubmit('submitAddattribute')) { $this->table = 'attribute'; $this->className = 'Attribute'; $this->identifier = 'id_attribute'; + + if ($this->display == 'edit') + $this->display = 'editAttributes'; } - - parent::initProcess(); - if ($this->table == 'attribute') - $this->display = 'editAttributes'; } /**