diff --git a/VERSIONS_HOTLINE/72568 b/VERSIONS_HOTLINE/72568 new file mode 100644 index 0000000000000000000000000000000000000000..0e7ffebf575bd3396c86cd3b50ad3109230344e4 --- /dev/null +++ b/VERSIONS_HOTLINE/72568 @@ -0,0 +1,2 @@ + - ticket #72568 : Adminitration : correction de la sauvegarde des checkbox lors de la modification multiple d'albums. + \ No newline at end of file diff --git a/library/ZendAfi/Controller/Plugin/Manager/Album.php b/library/ZendAfi/Controller/Plugin/Manager/Album.php index e341befd9b3e05e64d23e7134105a5ffe5815156..f40ea1dc11fd9997e72ba9c82a17018001edc9e9 100644 --- a/library/ZendAfi/Controller/Plugin/Manager/Album.php +++ b/library/ZendAfi/Controller/Plugin/Manager/Album.php @@ -417,9 +417,12 @@ class ZendAfi_Controller_Plugin_Manager_Album extends ZendAfi_Controller_Plugin_ protected function _validateAndSaveAlbum($album, $form) { $this->_view->form = $form; - if (!$this->_request->isPost() || !$form->isValid($this->_request->getPost())) + if (!$this->_request->isPost()) return; + if(!$form->isValid($this->_request->getPost())) + return $this->_helper->notify($this->_('Formulaire invalide, modification impossible')); + $values = $form->getValues(); unset($values['fichier']); unset($values['pdf']); diff --git a/library/ZendAfi/Controller/Plugin/MultiSelection/Abstract.php b/library/ZendAfi/Controller/Plugin/MultiSelection/Abstract.php index dd9e4545641b21c9019e4959de439e5385a5f47e..1a6841decaec38920abdbb1c8df4d97235ab74df 100644 --- a/library/ZendAfi/Controller/Plugin/MultiSelection/Abstract.php +++ b/library/ZendAfi/Controller/Plugin/MultiSelection/Abstract.php @@ -111,21 +111,22 @@ abstract class ZendAfi_Controller_Plugin_MultiSelection_Abstract extends ZendAfi $this->_view->form = $form; if (!$this->_request->isPost()) - return false; + return; + if(!$post = $this->processMulticheckboxFromPost($form,true)) - return false; + return $this->_helper->notify($this->_('Les données transmises sont vide. Les modifications n\'ont pas été prises en compte.')); foreach($models as $model) { $model->updateAttributes($post); if ((!$form->isValidModelAndArray($model, $this->_getPost()))) - return false; + return $this->_helper->notify($this->_('Le formulaire est invalide. Les modifications n\'ont pas été prises en compte.')); $this->_doBeforeSave($model); - if (!$model->save()) - return false; + if (!$model->save()) + return $this->_helper->notify($this->_('La sauvegarde a échoué. Les modifications n\'ont pas été prises en compte.')); $model_values = $this->_getCustomFieldModelValues($model); $custom_form = $this->_getCustomFieldForm($model_values); @@ -135,6 +136,7 @@ abstract class ZendAfi_Controller_Plugin_MultiSelection_Abstract extends ZendAfi $this->_doAfterSave($model); } + return true; } diff --git a/library/ZendAfi/Form/Album.php b/library/ZendAfi/Form/Album.php index bcc79e2a2b5a308cadf4ff346e8f2401bbd976cb..39c1b1480026afa406428d86ce9def493edeb1aa 100644 --- a/library/ZendAfi/Form/Album.php +++ b/library/ZendAfi/Form/Album.php @@ -399,7 +399,11 @@ class ZendAfi_Form_Album extends ZendAfi_Form { public function deleteUnchanged($post) { $this->isValid($post); - $post = array_filter($this->getValues()); + $post = array_filter($this->getValues(), + function($value) + { + return null !== $value; + }); return parent::deleteUnchanged($post); } } \ No newline at end of file diff --git a/tests/scenarios/MultiSelection/MultiSelectionTest.php b/tests/scenarios/MultiSelection/MultiSelectionTest.php index ea7beb6b85aba24a37ec51575ff8e9798c31fe9e..f46fdbe422c9fb44adb729e72c6d471194a4f39a 100644 --- a/tests/scenarios/MultiSelection/MultiSelectionTest.php +++ b/tests/scenarios/MultiSelection/MultiSelectionTest.php @@ -825,7 +825,9 @@ class MultiSelectionAlbumPostDatasTest extends MultiSelectionAlbumTestCase { 'fonction' => ['author'], 'keepValueOf_authors' => 0, 'editor' => ['Glénat'], - 'keepValueOf_editors' => 1]); + 'keepValueOf_editors' => 1, + 'visible' => 0, + 'keepValueOf_visible' => 0]); } @@ -878,6 +880,12 @@ class MultiSelectionAlbumPostDatasTest extends MultiSelectionAlbumTestCase { } + /** @test */ + public function firstAlbumShouldNotBeIndexed() { + $this->assertEquals('0', Class_Album::find(1)->getVisible()); + } + + /** @test */ public function shouldNotifySuccess() { $this->assertFlashMessengerEquals([ ['notification' => ['message' => 'Les 2 albums sélectionnés ont bien été sauvegardés']]]);