From be205a1a1c0dc9163f842efd9be816a65f898f0c Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Mon, 12 Nov 2012 09:30:18 +0000 Subject: [PATCH] =?UTF-8?q?Refacto=20pour=20simplifier=20la=20g=C3=A9n?= =?UTF-8?q?=C3=A9ration=20de=20formulaires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controllers/AlbumController.php | 3 ++- library/ZendAfi/Controller/Action.php | 6 ++---- .../Controller/Action/RessourceDefinitions.php | 16 ++-------------- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/application/modules/admin/controllers/AlbumController.php b/application/modules/admin/controllers/AlbumController.php index 8bd38f39dbd..2612c77fa17 100644 --- a/application/modules/admin/controllers/AlbumController.php +++ b/application/modules/admin/controllers/AlbumController.php @@ -500,7 +500,7 @@ class Admin_AlbumController extends Zend_Controller_Action { $groups = ['thumbnails' => ['legend' => 'Vignettes', 'elements' => ['thumbnail_width' => $textInputWithLabel('Largeur')]]]; - if ($album->isLivreNumerique()) + if ($album->isLivreNumerique()) { $groups['thumbnails']['elements']['display_one_page'] = ['element' => 'checkbox', 'options' => ['label' => $this->_('Monopage')]]; @@ -520,6 +520,7 @@ class Admin_AlbumController extends Zend_Controller_Action { 'thumbnail_right_page_crop_right' => $textInputWithLabel('Rognage droit'), 'thumbnail_right_page_crop_bottom' => $textInputWithLabel('Rognage bas'), 'thumbnail_right_page_crop_left' => $textInputWithLabel('Rognage gauche')]]]); + } return $this ->_thumbnailsFormWithFields($groups) diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php index df41761e4c3..0858d2628d2 100644 --- a/library/ZendAfi/Controller/Action.php +++ b/library/ZendAfi/Controller/Action.php @@ -114,10 +114,8 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action { */ protected function _getForm($model) { if (!$form = $this->_definitions->getForm()) { - $form = $this->view->newForm(array('id' => $this->_definitions->getModelName())); - $this->_definitions - ->addFormElements($form) - ->addDisplayGroups($form); + $form = new ZendAfi_Form( ['id' => $this->_definitions->getModelName()] ); + $form->populateFormFromGroupsDefinitions($this->_definitions->getDisplayGroups()); } return $form diff --git a/library/ZendAfi/Controller/Action/RessourceDefinitions.php b/library/ZendAfi/Controller/Action/RessourceDefinitions.php index a8f8e8cbcfd..265fda02370 100644 --- a/library/ZendAfi/Controller/Action/RessourceDefinitions.php +++ b/library/ZendAfi/Controller/Action/RessourceDefinitions.php @@ -157,20 +157,8 @@ class ZendAfi_Controller_Action_RessourceDefinitions { } - public function addDisplayGroups($form) { - foreach($this->_definitions['display_groups'] as $name => $definition) - $form->addDisplayGroup(array_keys($definition['elements']), - $name, - array('legend' => $definition['legend'])); - } - - - public function getFormElementDefinitions() { - $definitions = array(); - foreach($this->_definitions['display_groups'] as $group) - $definitions = array_merge($definitions, $group['elements']); - - return $definitions; + public function getDisplayGroups() { + return $this->_definitions['display_groups']; } -- GitLab