diff --git a/modules/blockmanufacturer/blockmanufacturer.php b/modules/blockmanufacturer/blockmanufacturer.php
index 3774a527d..b9184a5f3 100644
--- a/modules/blockmanufacturer/blockmanufacturer.php
+++ b/modules/blockmanufacturer/blockmanufacturer.php
@@ -76,12 +76,12 @@ class BlockManufacturer extends Module
public function getContent()
{
- $output = '
'.$this->displayName.'
';
+ $output = '';
if (Tools::isSubmit('submitBlockManufacturers'))
{
- $text_list = (int)(Tools::getValue('text_list'));
- $text_nb = (int)(Tools::getValue('text_nb'));
- $form_list = (int)(Tools::getValue('form_list'));
+ $text_list = (int)(Tools::getValue('MANUFACTURER_DISPLAY_TEXT'));
+ $text_nb = (int)(Tools::getValue('MANUFACTURER_DISPLAY_TEXT_NB'));
+ $form_list = (int)(Tools::getValue('MANUFACTURER_DISPLAY_FORM'));
if ($text_list && !Validate::isUnsignedInt($text_nb))
$errors[] = $this->l('There is an invalid number of elements');
elseif (!$text_list && !$form_list)
@@ -98,35 +98,7 @@ class BlockManufacturer extends Module
else
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
- return $output.$this->displayForm();
- }
-
- public function displayForm()
- {
- $output = '
- ';
- return $output;
+ return $output.$this->renderForm();
}
public function hookHeader($params)
@@ -148,4 +120,90 @@ class BlockManufacturer extends Module
{
$this->_clearCache('blockmanufacturer.tpl');
}
+
+ public function renderForm()
+ {
+ $fields_form = array(
+ 'form' => array(
+ 'legend' => array(
+ 'title' => $this->l('Settings'),
+ 'icon' => 'icon-cogs'
+ ),
+ 'input' => array(
+ array(
+ 'type' => 'switch',
+ 'label' => $this->l('Use a plain-text list'),
+ 'name' => 'MANUFACTURER_DISPLAY_TEXT',
+ 'desc' => $this->l('Display manufacturers in a plain-text list'),
+ 'values' => array(
+ array(
+ 'id' => 'active_on',
+ 'value' => 1,
+ 'label' => $this->l('Enabled')
+ ),
+ array(
+ 'id' => 'active_off',
+ 'value' => 0,
+ 'label' => $this->l('Disabled')
+ )
+ ),
+ ),
+ array(
+ 'type' => 'text',
+ 'label' => $this->l('Elements number'),
+ 'name' => 'MANUFACTURER_DISPLAY_TEXT_NB',
+ 'class' => 'fixed-width-xs'
+ ),
+ array(
+ 'type' => 'switch',
+ 'label' => $this->l('Use a drop-down list'),
+ 'name' => 'MANUFACTURER_DISPLAY_FORM',
+ 'desc' => $this->l('Display manufacturers in a drop-down list.'),
+ 'values' => array(
+ array(
+ 'id' => 'active_on',
+ 'value' => 1,
+ 'label' => $this->l('Enabled')
+ ),
+ array(
+ 'id' => 'active_off',
+ 'value' => 0,
+ 'label' => $this->l('Disabled')
+ )
+ ),
+ )
+ ),
+ 'submit' => array(
+ 'title' => $this->l('Save'),
+ 'class' => 'btn btn-primary')
+ ),
+ );
+
+ $helper = new HelperForm();
+ $helper->show_toolbar = false;
+ $helper->table = $this->table;
+ $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
+ $helper->default_form_language = $lang->id;
+ $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
+ $helper->identifier = $this->identifier;
+ $helper->submit_action = 'submitBlockManufacturers';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;
+ $helper->token = Tools::getAdminTokenLite('AdminModules');
+ $helper->tpl_vars = array(
+ 'fields_value' => $this->getConfigFieldsValues(),
+ 'languages' => $this->context->controller->getLanguages(),
+ 'id_language' => $this->context->language->id
+ );
+
+ return $helper->generateForm(array($fields_form));
+ }
+
+ public function getConfigFieldsValues()
+ {
+ return array(
+ 'MANUFACTURER_DISPLAY_TEXT' => Tools::getValue('MANUFACTURER_DISPLAY_TEXT', Configuration::get('MANUFACTURER_DISPLAY_TEXT')),
+ 'MANUFACTURER_DISPLAY_TEXT_NB' => Tools::getValue('MANUFACTURER_DISPLAY_TEXT_NB', Configuration::get('MANUFACTURER_DISPLAY_TEXT_NB')),
+ 'MANUFACTURER_DISPLAY_FORM' => Tools::getValue('MANUFACTURER_DISPLAY_FORM', Configuration::get('MANUFACTURER_DISPLAY_FORM')),
+ );
+ }
}