From 8ba8edeaa5902b99b99b339fc17834d221dcbdfa Mon Sep 17 00:00:00 2001
From: efalcy <efalcy@afi-sa.fr>
Date: Thu, 18 Feb 2016 14:44:31 +0100
Subject: [PATCH] dev #32668 : bibview display select custom field

---
 library/ZendAfi/Form/Admin/Library.php              |  8 ++++++--
 library/ZendAfi/View/Helper/BibView.php             |  2 +-
 .../modules/opac/controllers/BibControllerTest.php  | 13 +++++++++++++
 3 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/library/ZendAfi/Form/Admin/Library.php b/library/ZendAfi/Form/Admin/Library.php
index 4be9922f4de..3651da98fac 100644
--- a/library/ZendAfi/Form/Admin/Library.php
+++ b/library/ZendAfi/Form/Admin/Library.php
@@ -192,11 +192,15 @@ class ZendAfi_Form_Admin_Library extends ZendAfi_Form {
     return $this;
   }
 
-  protected function getCustomDisplayGroup() {
-    return $this->getDisplayGroup('informations');
 
+  protected function getCustomDisplayGroup() {
+    return new Zend_Form_DisplayGroup('custom_fields',
+                                      $this->getPluginLoader(self::DECORATOR),
+                                      ['legend' => $this->_('Champs personnalisés'),
+                                       'order' => 999]);
   }
 
+
   protected function displayRedmine() {
     if (!Class_AdminVar::isRedmineEnabled())
       return $this;
diff --git a/library/ZendAfi/View/Helper/BibView.php b/library/ZendAfi/View/Helper/BibView.php
index 82d9d06846e..2a1ab7bd6d1 100644
--- a/library/ZendAfi/View/Helper/BibView.php
+++ b/library/ZendAfi/View/Helper/BibView.php
@@ -189,7 +189,7 @@ class ZendAfi_View_Helper_BibView extends ZendAfi_View_Helper_BaseHelper {
     $content='';
     foreach($this->bib->getAllCustomFields()->getFieldValues() as $field) {
       if ($field->getValue() === '')
-        return '';
+        continue;
 
       $count++;
       $content.=$this->_renderBlock($this->_renderOptions($field,$count),$field->getLabel(),'custom'.$count);
diff --git a/tests/application/modules/opac/controllers/BibControllerTest.php b/tests/application/modules/opac/controllers/BibControllerTest.php
index 8ace17fd44e..c13f1ce69da 100644
--- a/tests/application/modules/opac/controllers/BibControllerTest.php
+++ b/tests/application/modules/opac/controllers/BibControllerTest.php
@@ -436,6 +436,16 @@ class BibControllerMultiCheckBoxCustomFieldsTest extends BibControllerBibViewTes
   public function setUp() {
     parent::setUp();
 
+
+    $this->custom_field = $this->fixture('Class_CustomField',
+                                          ['id' => 2,
+                                           'priority' => 3,
+                                           'field_type' => Class_CustomField_Meta::SELECT,
+                                           'label' => 'Mode',
+                                           'options_list' => 'Expert;Novice',
+                                           'model' => 'Bib']);
+
+
     $this->custom_field = $this->fixture('Class_CustomField',
                                           ['id' => 12,
                                            'priority' => 3,
@@ -444,6 +454,9 @@ class BibControllerMultiCheckBoxCustomFieldsTest extends BibControllerBibViewTes
                                            'field_type' => Class_CustomField_Meta::MULTI_CHECKBOX,
                                            'model' => 'Bib']);
 
+
+
+
     $this->bib_annecy->setCustomField('Services', ['Wifi', 'Restauration','l\'Médias']);
     $this->bib_annecy->saveWithCustomFields();
     $this->dispatch('bib/bibview/id/4', true);
-- 
GitLab