diff --git a/library/ZendAfi/View/Helper/Form.php b/library/ZendAfi/View/Helper/Form.php
new file mode 100644
index 0000000000000000000000000000000000000000..b2ace03015ae18b97ceb58b2f70e961759ec94f3
--- /dev/null
+++ b/library/ZendAfi/View/Helper/Form.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * BOKEH is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * BOKEH is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with BOKEH; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+
+class ZendAfi_View_Helper_Form extends ZendAfi_View_Helper_BaseHelper {
+  public function form($name, $attribs = null, $content = false) {
+    if (isset($attribs['id']))
+      $attribs['id'] = $this->view->escape($attribs['id']);
+
+    return $this->_tag('form',
+                       (false === $content
+                        ? null
+                        : $content),
+                       $attribs ? $attribs : []);
+  }
+}
\ No newline at end of file
diff --git a/library/templates/Intonation/System/Template.php b/library/templates/Intonation/System/Template.php
index 949be2859a22298d27f94087ef64e35972ae1a14..b239d6056e431e185a91402cb926a04424d83529 100644
--- a/library/templates/Intonation/System/Template.php
+++ b/library/templates/Intonation/System/Template.php
@@ -71,7 +71,8 @@ class Intonation_System_Template extends Intonation_System_Abstract {
                                                           'dd' => 'col-9',
                                                           'a' => 'btn-link',
                                                           'a class account-loans' => 'list-group-item-info',
-                                                          'ul' => 'list-unstyled'
+                                                          'ul' => 'list-unstyled',
+                                                          'form class indent-form' => 'px-4 py-1',
                                   ]];
 
 
diff --git a/library/templates/Intonation/View/Widget/Search.php b/library/templates/Intonation/View/Widget/Search.php
index 26c426598329dc24f94af0d163f606bd347191d9..ebfe25912478ec3c45e9d5c37fd7ea7ab378eb6e 100644
--- a/library/templates/Intonation/View/Widget/Search.php
+++ b/library/templates/Intonation/View/Widget/Search.php
@@ -31,18 +31,18 @@ class Intonation_View_Widget_Search extends ZendAfi_View_Helper_BaseHelper {
 
 
   protected function _getRenderStrategy() {
-    $preferences = $this->_settings->getPreferences();
+    $preferences = new Class_Entity($this->_settings->getPreferences());
 
-    if(!isset($preferences['IntonationFormStyle']))
-      return new IntonationSearchRenderDefault($this->view, $this->_settings, $this->_user);
+    if(!$style = $preferences->getIntonationFormStyle())
+      return new IntonationSearchRenderDefault($this->view, $preferences, $this->_user);
 
-    if('inline' == $preferences['IntonationFormStyle'])
-      return new IntonationSearchRenderInline($this->view, $this->_settings, $this->_user);
+    if('inline' == $style)
+      return new IntonationSearchRenderInline($this->view, $preferences, $this->_user);
 
-    if('toggle' == $preferences['IntonationFormStyle'])
-      return new IntonationSearchRenderToggle($this->view, $this->_settings, $this->_user);
+    if('toggle' == $style)
+      return new IntonationSearchRenderToggle($this->view, $preferences, $this->_user);
 
-    return new IntonationSearchRenderDefault($this->view, $this->_settings, $this->_user);
+    return new IntonationSearchRenderDefault($this->view, $preferences, $this->_user);
   }
 }
 
@@ -55,182 +55,194 @@ abstract class IntonationSearchRenderAbstract {
   protected
     $_view,
     $_settings,
-    $_user;
+    $_user,
+    $_id;
 
 
   public function __construct($view, $settings, $user) {
     $this->_view = $view;
     $this->_settings = $settings;
     $this->_user = $user;
+    $this->_id = $settings->getid_module();
   }
 
 
   protected function _getMainForm() {
-    $preferences = $this->_settings->getPreferences();
-
     $action_url = ['module' => 'opac',
                    'controller' => 'recherche',
                    'action' => 'simple'];
 
-    if (array_key_exists('type_doc', $preferences))
-      $action_url['facette'] = 'T' . $preferences['type_doc'];
+    if ($doc_type = $this->_settings->gettype_doc())
+      $action_url['facette'] = Class_TypeDoc::CODE_FACETTE . $doc_type;
 
-    if (array_key_exists('profil_redirect', $preferences))
-      $action_url['id_profil'] = $preferences['profil_redirect'];
+    if ($profile_id_redirect = $this->_settings->getprofil_redirect())
+      $action_url['id_profil'] = $profile_id_redirect;
 
     $action_url = $this->_view->url($action_url, null, true);
 
     $form = (new ZendAfi_Form)
-      ->setAction($action_url)
-      ->setAttrib('class', 'px-4 py-1');
+      ->setAttrib('class', 'indent-form')
+      ->setAction($action_url);
 
-    if (isset($preferences["type_doc"]) && $preferences["type_doc"])
+    if ($doc_type)
       $form ->addElement('hidden', 'type_doc');
 
-    $form->addElement('hidden', 'tri');
-    $form->addElement('search',
-                      'expressionRecherche' . $preferences['id_module'],
-                      ['label' => $preferences['message'],
-                       'class' => 'expressionRecherche',
-                       'placeholder' => $preferences['placeholder']])
-         ->addElement('submit',
-                      'search_submit',
-                      ['label' => $preferences['search_button'],
-                       'onclick' => '$(this).parents(\'form\').submit()',
-                       'order' => 10]);
+    $form
+      ->addElement('hidden',
+                   'tri',
+                   ['value' => $this->_settings->gettri()])
+
+      ->addElement('search',
+                   'expressionRecherche' . $this->_id,
+                   ['label' => $this->_settings->getmessage(),
+                    'class' => 'expressionRecherche',
+                    'placeholder' => $this->_settings->getplaceholder()])
+
+      ->addElement('submit',
+                   'search_submit',
+                   ['label' => $this->_settings->getsearch_button(),
+                    'onclick' => '$(this).parents(\'form\').submit()',
+                    'order' => 10]);
+
     return $form;
   }
 
 
   protected function _getForm() {
-    $preferences = $this->_settings->getPreferences();
     $form = $this->_getMainForm();
     $elements = $this->_getOptionalElements();
 
     return $form
       ->addElements($elements)
-      ->populate($preferences);
+      ->populate($this->_settings->toArray());
   }
 
 
   protected function _getOptionalElements() {
-    $preferences = $this->_settings->getPreferences();
-
     $form = new ZendAfi_Form;
     $elements = [];
 
-    if (isset($preferences["select_doc"]) && $preferences["select_doc"])
-      $elements [] = $form->createElement('select',
-                                          'custom_multifacets_doctype',
-                                          ['label' => $this->_('Type de document'),
-                                           'multiOptions' => Class_TypeDoc::getMultiOptionsFacets()]);
-
-    if (isset($preferences["select_annexe"]) && $preferences["select_annexe"])
-      $elements [] = $form->createElement('select',
-                                          'custom_multifacets_annexe',
-                                          ['label' => $this->_('Site'),
-                                           'multiOptions' => Class_CodifAnnexe::getMultiOptionsFacets()]);
-
-    $elements [] = $this->_createDomainElement();
-    return array_filter($elements);
+    if ($this->_settings->getselect_doc())
+      $elements [] =
+        $form->createElement('select',
+                             'custom_multifacets_doctype',
+                             ['label' => $this->_('Type de document'),
+                              'multiOptions' => Class_TypeDoc::getMultiOptionsFacets()]);
+
+    if ($this->_settings->getselect_annexe())
+      $elements [] =
+        $form->createElement('select',
+                             'custom_multifacets_annexe',
+                             ['label' => $this->_('Site'),
+                              'multiOptions' => Class_CodifAnnexe::getMultiOptionsFacets()]);
+
+    $elements = $this->_createDomainElement($elements);
+    return $elements;
   }
 
 
-  protected function _createDomainElement() {
-    $preferences = $this->_settings->getPreferences();
+  protected function _createDomainElement($elements) {
+    if (!$domain_ids = trim($this->_settings->getdomain_ids()))
+      return $elements;
 
-    if (!isset($preferences['domain_ids']))
-      return null;
-
-    if (!$domain_ids = array_filter(explode('-', trim($preferences['domain_ids'])), 'is_numeric'))
-      return null;
+    if (!$domain_ids = array_filter(explode('-', $domain_ids), 'is_numeric'))
+      return $elements;
 
     if (!$multi_options = Class_Catalogue::getMultiOptionsFacets($domain_ids))
-      return null;
+      return $elements;
 
     $form = $this->_getMainForm();
 
-    if (!isset($preferences['domain_select_style'])
-        || $preferences['domain_select_style'] == Class_Systeme_ModulesAccueil_RechercheSimple::DOMAIN_SELECT_SELECT)
-      return $form->createElement('select',
-                                  'custom_multifacets_domains',
-                                  ['label' => $this->_('Domaine de recherche'),
-                                   'multiOptions' => $multi_options]);
-
-    return $form->createElement('multiCheckbox',
-                                'custom_multifacets_domains',
-                                ['label' => $this->_('Restreindre à'),
-                                 'multiOptions' => array_slice($multi_options, 1, count($multi_options) -1, true)]);
+    $elements [] = (Class_Systeme_ModulesAccueil_RechercheSimple::DOMAIN_SELECT_SELECT
+        == $this->_settings->getdomain_select_style())
+      ? $form->createElement('select',
+                             'custom_multifacets_domains',
+                             ['label' => $this->_('Domaine de recherche'),
+                              'multiOptions' => $multi_options])
+      : $form->createElement('multiCheckbox',
+                             'custom_multifacets_domains',
+                             ['label' => $this->_('Restreindre à'),
+                              'multiOptions' => array_slice($multi_options,
+                                                            1,
+                                                            count($multi_options) -1,
+                                                            true)
+                             ]);
+
+    return $elements;
   }
 
 
-  abstract public function render();
-}
-
-
-
-
-class IntonationSearchRenderDefault extends IntonationSearchRenderAbstract {
-
-  public function render() {
-    $html = $this->_view->renderForm($this->_getForm()->addUniqDisplayGroup('search_group'));
-
-    if (isset($preferences["recherche_avancee"]) && in_array($preferences["recherche_avancee"], ['on', 1, '1'], true) )
-      $html .= $this->_view->tag('div',
-                                 '',
-                                 ['class' => 'dropdown-divider'])
-        . $this->_view->tagAnchor($this->_view->url(['controller' => 'recherche',
-                                                     'action' => 'avancee',
-                                                     'statut' => 'reset'],
-                                                    null,
-                                                    true),
-                                  $this->_('Recherche avancée'),
-                                  ['class' => 'dropdown-item',
-                                   'title' => $this->_('Accéder au formulaire de recherche avancée')]);
-
-    return $html;
+  protected function _isAdvancedSearchEnabled() {
+    return in_array($this->_settings->getrecherche_avancee(), ['on', 1, '1'], true);
   }
-}
-
 
 
+  protected function _renderAdvancedSearch() {
+    return $this->_view->tag('div',
+                             '',
+                             ['class' => 'dropdown-divider'])
+      . $this->_view->tagAnchor($this->_view->url(['controller' => 'recherche',
+                                                   'action' => 'avancee',
+                                                   'statut' => 'reset'],
+                                                  null,
+                                                  true),
+                                $this->_('Recherche avancée'),
+                                ['class' => 'dropdown-item',
+                                 'title' => $this->_('Accéder au formulaire de recherche avancée')]);
+  }
 
-class IntonationSearchRenderToggle extends IntonationSearchRenderDefault {
-  public function render() {
-    $html = parent::render();
-    $preferences = $this->_settings->getPreferences();
 
+  protected function _renderToggle($html, $button_text = '') {
     Class_ScriptLoader::getInstance()
       ->addJqueryReady('$(".dropdown-menu").on("click", function (e) {e.stopPropagation();});');
 
+    $id = 'dropdown_button_' . $this->_id;
+
     return $this->_view->tag('div',
                              $this->_view->tag('button',
-                                               $preferences['message'],
-                                               ['id' => $preferences['id_module'],
+                                               $button_text,
+                                               ['id' => $id,
                                                 'data-toggle' => 'dropdown',
                                                 'aria-haspopup' => 'true',
                                                 'type' => 'button',
                                                 'class' => 'search-button btn dropdown-toggle'])
                              . $this->_view->tag('div',
                                                  $html,
-                                                 ['class' => 'dropdown-menu',
-                                                  'aria-labelledby' => $preferences['id_module']]),
+                                                 ['class' => 'dropdown-menu px-4 py-1',
+                                                  'aria-labelledby' => $id]),
                              ['class' => 'dropdown']);
   }
+
+
+  abstract public function render();
 }
 
 
 
-class IntonationSearchRenderInline extends IntonationSearchRenderAbstract {
+class IntonationSearchRenderDefault extends IntonationSearchRenderAbstract {
 
   public function render() {
-    $preferences = $this->_settings->getPreferences();
+    $html = $this->_view->renderForm($this->_getForm()
+                                     ->addUniqDisplayGroup('search_group'));
+
+    return $this->_isAdvancedSearchEnabled()
+      ? $html . $this->_renderAdvancedSearch()
+      : $html;
+  }
+}
+
+
+
+class IntonationSearchRenderToggle extends IntonationSearchRenderDefault {
+  public function render() {
+    return $this->_renderToggle(parent::render(), $this->_settings->getmessage());
+  }
+}
 
-    $expression = 'expressionRecherche' . $preferences['id_module'];
-    $submit = 'search_submit';
 
-    $form = $this->_getMainForm();
 
+class IntonationSearchRenderInline extends IntonationSearchRenderAbstract {
+  public function render() {
     $optional_form_elements = [];
 
     foreach($this->_getOptionalElements() as $element) {
@@ -238,81 +250,23 @@ class IntonationSearchRenderInline extends IntonationSearchRenderAbstract {
       $optional_form_elements [] = $element->render($this->_view);
     }
 
-    /* $optional_form_elements = [(new ZendAfi_Form)->addElements($this->_getOptionalElements())->render($this->_view)]; */
-
-
-    $advanced_search = (isset($preferences["recherche_avancee"])
-                        && in_array($preferences["recherche_avancee"], ['on', 1, '1'], true))
-      ? $this->_view->tag('div',
-                          $this->_view->tag('button',
-                                               '',
-                                               ['id' => $preferences['id_module'],
-                                                'data-toggle' => 'dropdown',
-                                                'aria-haspopup' => 'true',
-                                                'type' => 'button',
-                                                'class' => 'search-button mr-1 btn-sm dropdown-toggle'])
-                          . $this->_view->tag('div',
-                                              $this->_view->tagAnchor($this->_view->url(['controller' => 'recherche',
-                                                                                         'action' => 'avancee',
-                                                                                         'statut' => 'reset'],
-                                                                                        null,
-                                                                                        true),
-                                                                      $this->_('Recherche avancée'),
-                                                                      ['title' => $this->_('Accéder au formulaire de recherche avancée'),
-                                                                       'class' => 'dropdown-item']),
-                                              ['class' => 'dropdown-menu',
-                                               'aria-labelledby' => $preferences['id_module']]),
-                          ['class' => 'dropdown'])
+    $advanced_search = $this->_isAdvancedSearchEnabled()
+      ? $this->_renderAdvancedSearch()
       : '';
 
-    $form->addElement('custom',
-                      'custom_advanced_search',
-                      ['render' => function() use ($advanced_search, $optional_form_elements)
-                        {
-                          return $advanced_search . implode($optional_form_elements);
-                        }]);
+    $form = $this
+      ->_getMainForm()
+      ->addElement('custom',
+                   'custom_advanced_search',
+                   ['render' => function() use ($advanced_search,
+                                                $optional_form_elements)
+                     {
+                       $html = implode($optional_form_elements) . $advanced_search;
 
-    $form->addUniqDisplayGroup('search_group');
+                       return $this->_renderToggle($html);
+                     }]);
 
-    /* $elements = $form->getElements(); */
-    /* foreach($elements as $element) { */
-    /*   $element->setLabel(''); */
-    /* } */
-
-    /* $form->addDisplayGroup([$expression, */
-    /*                         $submit], */
-    /*                        'widget_search_form_inline'); */
-
-    /* $elements = array_filter($form->getElementsNames(), function($element) use ($expression, $submit) */
-    /*                          { */
-    /*                            return !in_array($element, [$expression, $submit]); */
-    /*                          }); */
-    /* if ($elements) */
-    /*   $form->addDisplayGroup($elements, */
-    /*                          'widget_search_form_inline_dropdown'); */
-
-    $html = $this->_view->renderInlineForm($form);
-    $preferences = $this->_settings->getPreferences();
-
-    /* if (isset($preferences["recherche_avancee"]) && in_array($preferences["recherche_avancee"], ['on', 1, '1'], true) ) */
-    /*   $html .= $this->_view->tag('div', */
-    /*                              $this->_view->tagAnchor('#', */
-    /*                                                      ' ', */
-    /*                                                      ['class' => 'btn btn-secondary dropdown-toggle', */
-    /*                                                       'role' => 'button', */
-    /*                                                       'data-toggle' => 'dropdown']) */
-    /*                              . $this->_view->tag('div', */
-    /*                                              $this->_view->tagAnchor($this->_view->url(['controller' => 'recherche', */
-    /*                                                                                         'action' => 'avancee', */
-    /*                                                                                         'statut' => 'reset'], */
-    /*                                                 null, */
-    /*                                                                                        true), */
-    /*                                                                      $this->_('Recherche avancée'), */
-    /*                                                                      ['title' => $this->_('Accéder au formulaire de recherche avancée'), */
-    /*                                                                       'class' => 'dropdown-item']), */
-    /*                                                  ['class' => 'dropdown-menu', */
-    /*                                                   'aria-labelledby' => $preferences['id_module']]), */
-    /*                              ['class' => 'dropdown']); */
-    return $html;
+    $form->addUniqDisplayGroup('search_group');
+    return $this->_view->renderInlineForm($form);
   }
 }
\ No newline at end of file
diff --git a/tests/scenarios/Templates/TemplatesTest.php b/tests/scenarios/Templates/TemplatesTest.php
index d4296929ea7b30555842063cad03914b83cfe4a5..4efd8920ba5d1215dda1d9250d99be9e44dbcf13 100644
--- a/tests/scenarios/Templates/TemplatesTest.php
+++ b/tests/scenarios/Templates/TemplatesTest.php
@@ -1202,7 +1202,7 @@ class TemplatesDispatchIntonationWithSearchWidgetToggleStyleTest extends Templat
 
   /** @test */
   public function searchWidgetShouldBeWrappedToggleForm() {
-    $this->assertXPath('//div[contains(@class,"boite rech_simple")]//div[@class="dropdown-menu"]//form');
+    $this->assertXPath('//div[contains(@class,"boite rech_simple")]//div[contains(@class, "dropdown-menu")]//form');
   }