I am trying to add a helper form that lets the user upload images for two languages that the user can select.
However I am stuck with the form and cannot render it in the view. Here is my controller code:
<?php
class AdminWineoHeaderImgController extends ModuleAdminController
{
public function __construct()
{
$this->bootstrap = true;
$this->lang = (!isset($this->context->cookie) ||
!is_object($this->context->cookie)) ? intval(Configuration::get('PS_LANG_DEFAULT')) : intval($this->context->cookie->id_lang);
parent::__construct();
}
public function display()
{
parent::display();
}
public function renderList()
{
$this->renderForm();
$return = $this->context->smarty->fetch(_PS_MODULE_DIR_.'wineoheaderimg/views/templates/hook/adminwineoimg.tpl');
return $return;
}
public function renderForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->module->l('Wineo Header Img Configuration'),
'icon' => 'icon-envelope',
),
'input' => array(
array(
'type' => 'file',
'label' => $this->module->l('Add images'),
'name' => 'enable_grades',
'id' => 'uploadwineoheaderimg',
'required' => false,
'desc' => $this->module->l('Choose images that will appear on the front page.'),
),
array(
'type' => 'select',
'label' => $this->l('Languages:'),
'name' => 'category',
'required' => true,
'options' => array(
'query' => $options = array(
array(
'id_option' => 1, // The value of the 'value' attribute of the <option> tag.
'name' => 'EN', // The value of the text content of the <option> tag.
),
array(
'id_option' => 2,
'name' => 'BG',
),
),
'id' => 'id_option',
'name' => 'name',
),
),
),
'submit' => array('title' => $this->module->l('Save')),
),
);
$helper = new HelperForm();
$helper->table = 'wineoheaderimg';
$helper->default_form_language = (int) Configuration::get('PS_LANG_DEFAULT');
$helper->allow_employee_form_lang = (int) Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG');
$helper->submit_action = 'wineo_header_img_pc_form';
$helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->module->name.'&tab_module='.$this->module->tab.'&module_name='.$this->module->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->tpl_vars = array(
'fields_value' => array(
'wineo_header_img' => Tools::getValue('enable_grades', Configuration::get('WINEO_HEADER_IMG')),
),
'languages' => $this->context->controller->getLanguages(),
);
return $helper->generateForm(array($fields_form));
}
}
Where should I call the method renderForm()? I have tried in the admin hooks and basically everywhere I could imagine.
Any help will be appreciated!
Well you are calling renderForm() inside renderList(), (I assume you want the form to display by default when you open controller page) but you don't assign the form to template.
public function renderList()
{
$form = $this->renderForm();
// To load form inside your template
$this->context->smarty->assign('form_tpl', $form);
return $this->context->smarty->fetch(_PS_MODULE_DIR_.'wineoheaderimg/views/templates/hook/adminwineoimg.tpl');
// To return form html only
return $form;
}
So if you want the form inside your adminwineoimg.tpl
{* Some HTML *}
{$form_tpl}
{* Some HTML *}
Related
I can't figure out how to display, in my custom admin controller, 1 fields_list + content of a .tpl file. The goal is to display my product keys in stock + some extra features below (content from a tpl file).
I can display either the fields list OR the message from the .tpl file. But not combined... I found a tutorial online and this comes very close, but not working.
<?php
require_once(_PS_MODULE_DIR_ . 'avanto_key/classes/AvantoStock.php');
class AdminAvantokeyStockController extends ModuleAdminController
{
protected $position_identifier = 'id_avanto_keys';
public function __construct()
{
//$this->fields_form = $this->fieldForm();
$this->bootstrap = true;
$this->table = 'avanto_keys'; // DB table name where your object data stored
$this->className = "AvantoStock"; // The class name of my object
//$this->identifier = 'id_avanto_keys';
//$this->list_id = 'id_avanto_keys';
$this->_defaultOrderBy = 'id_avanto_keys';
//$this->lang = FALSE;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'),
'confirm' => $this->l('Delete selected items?')), );
//Shop::addTableAssociation($this->table, array('type' => 'shop'));
parent::__construct();
$this->_select = 'pl.`name` as product_name, a.`serial_key` as serial_display';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = a.`id_product` AND pl.`id_lang`
= '.(int)$this->context->language->id.')';
}
public function renderView()
{
$tpl = $this->context->smarty->createTemplate(
dirname(__FILE__).
'/../../views/templates/admin/view.tpl');
return $tpl->fetch();
}
public function renderList()
{
$this->toolbar_title = $this->l('Stock Management');
$this->toolbar_btn['new'] = null;
$this->fields_list = array(
'id_avanto_keys' => array(
'title' => $this->l('ID Key'),
'width' => 140,
),
'id_product' => array(
'title' => $this->l('Product ID'),
'width' => 140,
),
'serial_key' => array(
'title' => $this->l('Serial Keys'),
'width' => 140,
),
'product_name' => array(
'title' => $this->l('Product Name'),
'width' => 140,
),
);
return parent::renderList();
}
public function init()
{
parent::init();
}
public function initContent()
{
$this->context->smarty->assign(array(
'form' => $form,
'base_dir' => _PS_MODULE_DIR_,
));
$this->setTemplate('stock.tpl');
$lists = parent::initContent();
$this->renderList();
$lists .= parent::initContent();
return $lists;
}
public function renderForm()
{
$this->display = 'edit';
$this->initToolbar();
$this->fields_form = array(
'tinymce' => true,
'legend' => array(
'title' => $this->l('Edit product key'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Key ID'),
'name' => 'id_product',
),
array(
'type' => 'text',
'label' => $this->l('Product ID'),
'name' => 'id_avanto_keys',
),
array(
'type' => 'text',
'label' => $this->l('Serial Key'),
'required' => true,
'name' => 'serial_key',
),
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'btn btn-default pull-right'
)
);
return parent::renderForm();
}
}
?>
The code above only displays the message hello world and not my product listing.
Anyone has an idea how to combine this?
Thanks in advance!!!
It's a little bit confused, we have to make some tidy :):
First:
The fields of the list it's better to declare in the __construct so:
public function __construct()
{
$this->module = 'YourModuleName'; // Here you have to put your module name
$this->bootstrap = true;
$this->table = 'avanto_keys'; // DB table name where your object data stored
$this->className = "AvantoStock"; // The class name of my object
//$this->identifier = 'id_avanto_keys';
//$this->list_id = 'id_avanto_keys';
$this->_defaultOrderBy = 'id_avanto_keys';
//$this->lang = FALSE;
$this->explicitSelect = true; // This if you do a select manually after
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'),
'confirm' => $this->l('Delete selected items?')), );
//Shop::addTableAssociation($this->table, array('type' => 'shop'));
$this->_select = 'pl.`name` as product_name, a.`serial_key` as serial_display';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (pl.`id_product` = a.`id_product` AND pl.`id_lang`
= '.(int)$this->context->language->id.')';
$this->fields_list = array(
'id_avanto_keys' => array(
'title' => $this->l('ID Key'),
'width' => 140,
),
'id_product' => array(
'title' => $this->l('Product ID'),
'width' => 140,
),
'serial_key' => array(
'title' => $this->l('Serial Keys'),
'width' => 140,
),
'product_name' => array(
'title' => $this->l('Product Name'),
'width' => 140,
),
);
parent::__construct();
}
Second
The parent renderList method make other stuff, let's separate that from what do you want to display:
public function renderList()
{
// Here we retrieve the list (without doing any strange thing)
$list = parent::renderList();
// Assign some vars to pass to our custom tpl
$this->context->smarty->assign(
array(
'var1' => "Test",
'var2' => "Test2"
)
);
// Get the custom tpl rendered
$content = $this->context->smarty->fetch(_PS_MODULE_DIR_ . "avanto_key/views/templates/admin/avantokeystock/customcontent.tpl");
// return the list plus your content
return $list . $content;
}
Third
Leave the parent initContent as is, do not override, because he make a lot of stuffs
I guess that is a great point to start :)
Try this way and let me know ;)
I have a problem in validating the array of value of an element. I search a lot find a callback function to validate that data.
Below is the validation code which i am using but it is not working
<?php
namespace Tutorials\Form;
use Zend\InputFilter\Factory as InputFactory; // <-- Add this import
use Zend\InputFilter\InputFilter; // <-- Add this import
use Zend\InputFilter\InputFilterAwareInterface; // <-- Add this import
use Zend\InputFilter\InputFilterInterface;
use Zend\Validator\Callback;
use Zend\I18n\Validator\Alpha;
class AddSubTopicFilterForm extends InputFilter implements InputFilterAwareInterface {
protected $inputFilter;
public $topicData;
public $subTopicData;
function __construct($data = array()) {
$articles = new \Zend\InputFilter\CollectionInputFilter();
$articlesInputFilter = new \Zend\InputFilter\InputFilter();
$articles->setInputFilter($articlesInputFilter);
$this->add(new \Zend\InputFilter\Input('title'));
$this->add($articles, 'articles');
if(!empty($data['data']['topic_name'])) {
$this->topicData = $data['data']['topic_name'];
}
if(!empty($data['data']['sub_topic_name'])) {
$this->subTopicData = $data['data']['sub_topic_name'];
}
}
public function setInputFilter(InputFilterInterface $inputFilter){
throw new \Exception("Not used");
}
public function getInputFilter(){
if (!$this->inputFilter) {
$dataTopic = $this->topicData;
$dataSubTopic = $this->subTopicData;
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array(
'name' => 'topic_name',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'Callback',
'options' => array(
'messages' => array(
\Zend\Validator\Callback::INVALID_VALUE => 'Seletec value is not valid',
),
"callback" => function() use ($dataTopic) {
$strip = new \Zend\I18n\Validator\IsInt();
foreach($dataTopic as $key => $tag) {
$tag = $strip->isValid((int)$tag);
$dataTopic[$key] = $tag;
}
return $dataTopic;
},
),
),
),
)));
$inputFilter->add($factory->createInput(array(
'name' => 'sub_topic_name',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'Callback',
'options' => array(
'messages' => array(
\Zend\Validator\Callback::INVALID_VALUE => 'Invalid Sub Topic Name',
),
"callback" => function() use ($dataSubTopic) {
$strip = new \Zend\Validator\StringLength(array('encoding' => 'UTF-8','min' => 1,'max' => 100));
foreach($dataSubTopic as $key => $tag) {
$tag = $strip->isValid($tag);
$dataSubTopic[$key] = $tag;
}
return $dataSubTopic;
},
),
),
),
)));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
}
In the above line of code the value of
$data['data']['topic_name']=array('0' => 1,'1' => 1)
and $data['data']['sub_topic_name']=array('0'=>'Testing','1'=>'Testing1');
and i am calling it
$form = new AddSubTopicForm();
$logFilterForm = new AddSubTopicFilterForm();
$form->setInputFilter($logFilterForm->getInputFilter());
$form->setData($request->getPost());
Below is the of the form class
<?php
namespace Tutorials\Form;
use Zend\Form\Element;
use Zend\Form\Form;
class AddSubTopicForm extends Form {
public function __construct($data = array()){
parent::__construct('AddSubTopic');
$this->setAttribute('class', 'form-horizontal');
$this->setAttribute('novalidate', 'novalidate');
$this->add(array(
'type' => 'Zend\Form\Element\Select',
'name' => 'topic_name[]',
'attributes' => array(
'id' => 'topic_name',
'class' => 'form-control',
),
'options' => array(
'label' => ' Topic Name',
'empty_option'=>'---None--- ',
'value_options' => array(
'1' => 'PHP'
),
),
));
$this->add(array(
'name' => 'sub_topic_name[]',
'attributes' => array(
'type' => 'text',
'id' => 'sub_topic_name',
'class' => 'form-control',
'value' => ''
),
'options' => array(
'label' => ' Sub Topic Name',
),
));
$this->add(array(
'name' => 'id',
'attributes' => array(
'type' => 'hidden',
'id' => 'id'
)
));
$button = new Element('add_more_sub_topic');
$button->setValue('+AddMore');
$button->setAttributes(array(
'type' => 'button',
'id'=>'add_more',
'class'=>'btn btn-info'
));
$save = new Element('save');
$save->setValue('Save');
$save->setAttributes(array(
'type' => 'submit',
'id'=>'save',
'class'=>'btn btn-info'
));
$reset = new Element('reset');
$reset->setValue('Reset');
$reset->setAttributes(array(
'type' => 'reset',
'id'=>'reset',
'class'=>'btn'
));
$this->add($button);
$this->add($save);
$this->add($reset);
}//end of function_construct.
}//end of registration form class.
But it is not calling the filter callback function rather give me an error on first first form field that 'value is required ,can't be empty'
I don't why it is not validating data.Suggest me what where i am wrong and how can i overcome from this problem. Any help would be appreciated. Than.x
I am using the Zend Framework 2 and notice my sql queries are running twice when pulling values from the database to use in my Forms. I can see in the developertool that it is running twice (two different run times). It only happens with the form elements (not when I echo query results into a table)
I used the below link as a guide:
http://samminds.com/2013/03/zendformelementselect-and-database-values/
Thanks
M
Controller Action
public function indexAction() //Display the pro greetings page
{
$this->layout()->setVariable('menu', 'verified');
$dbAdapter = $this->getServiceLocator()->get('Zend\Db\Adapter\Adapter');
$form = new ProLicenceForm($dbAdapter);
$form->get('submit')->setValue('Submit');
$pro_id='22';
$proBackEnd = new ProSide($dbAdapter);
$form->get('pro_id')->setValue($pro_id);
// $user_id=$this->zfcUserAuthentication()->getIdentity()->getId(); //causes error if not register need to block or add logic to redirect
// $form->get('user_id')->setValue($user_id); //pass the user id from the user module
$request = $this->getRequest();
if ($request->isPost()) {
$proLicence = new ProLicence();
$form->setInputFilter($proLicence->getInputFilter());
$form->setData($request->getPost());
if ($form->isValid()) {
$proLicence->exchangeArray($form->getData());
$this->getProLicenceTable()->saveProLicence($proLicence);
// return $this->redirect()->toRoute('pro', array('action'=>'proVerification')); //redirect to next step
}
else {
echo "ERROR HOMMIE";
}
}
return array(
'form' => $form,
'proLicences' => $proBackEnd->getProSideLicence($pro_id),
);
}
Form
<?php
namespace Pro\Form;
use Zend\Form\Form;
use Zend\Db\Adapter\AdapterInterface;
class ProLicenceForm extends Form
{
public function __construct(AdapterInterface $dbAdapter)
{
// $this->setDbAdapter($dbAdapter);
$this->adapter =$dbAdapter;
// we want to ignore the name passed
parent::__construct('pro-licence-form');
$this->add(array(
'name' => 'pro_id',
'type' => 'Hidden',
));
$this->add(array(
'name' => 'licence_id',
'type' => 'Hidden',
'options' => array(
),
'attributes' => array(
//'required' => 'required'
)
));
$this->add(array(
'name' => 'licence_name_id',
'type' => 'Zend\Form\Element\Select',
'options' => array(
'label' => 'Licence',
'value_options' => $this->getLicenceOptions(),
'empty_option' => '--- please choose ---'
),
'attributes' => array(
'placeholder' => 'Choose all that apply'
)
));
$this->add(array(
'name' => 'licence_number',
'type' => 'Text',
'options' => array(
'label' => 'Licence Number'
)
));
$this->add(array(
'name' => 'submit',
'type' => 'Submit',
'options' => array(
'label'=> 'Primary Button',
),
'attributes' => array(
'value' => 'Go',
'id' => 'submitbutton',
),
));
}
/*
* SQL statements used to bring in optiosn
*/
public function getLicenceOptions()
{
$dbAdapter = $this->adapter;
$sql = 'SELECT licence_name_id,licence_name FROM licence_name_table ORDER BY licence_name';
$statement = $dbAdapter->query($sql);
$result = $statement->execute();
$selectData = array();
foreach ($result as $res) {
$selectData[$res['licence_name_id']] = $res['licence_name'];
}
return $selectData;
}
}
I am trying to create login page in zend framework2. I have created its view,controller,model and form. Even i m not getting any error.
following my code :
My model as Login.php is :
class Login implements InputFilterAwareInterface
{
public $id;
public $username;
public $password;
protected $inputFilter;
public function exchangeArray($data)
{
$this->id = (!empty($data['id'])) ? $data['id'] : null;
$this->username = (!empty($data['username'])) ? $data['username'] : null;
$this->password = (!empty($data['password'])) ? $data['password'] : null;
}
public function getArrayCopy()
{
return get_object_vars($this);
}
public function setInputFilter(InputFilterInterface $inputFilter)
{
throw new \Exception("Not used");
}
public function getInputFilter()
{
if (!$this->inputFilter) {
$inputFilter = new InputFilter();
$inputFilter->add(array(
'name' => 'id',
'required' => true,
'filters' => array(
array('name' => 'Int'),
),
));
$inputFilter->add(array(
'name' => 'username',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
),
),
),
));
$inputFilter->add(array(
'name' => 'password',
'required' => true,
'filters' => array(
array('name' => 'StripTags'),
array('name' => 'StringTrim'),
),
'validators' => array(
array(
'name' => 'StringLength',
'options' => array(
'encoding' => 'UTF-8',
'min' => 1,
'max' => 100,
),
),
),
));
$this->inputFilter = $inputFilter;
}
return $this->inputFilter;
}
}
My LoginForm is :
namespace Application\Form;
use Zend\Form\Form;
class LoginForm extends Form
{
public function __construct($name = null)
{
// we want to ignore the name passed
parent::__construct('tbluser');
$this->add(array(
'name' => 'id',
'type' => 'Hidden',
));
$this->add(array(
'name' => 'username',
'type' => 'Text',
'options' => array(
'label' => '',
),
'attributes' => array(
'id' => 'username',
'class'=>'',
'autocomplete'=>'OFF',
'max'=>'100',
),
));
$this->add(array(
'name' => 'password',
'type' => 'Text',
'options' => array(
'label' => '',
),
'attributes' => array(
'id' => 'password',
'class'=>'',
'autocomplete'=>'OFF',
'max'=>'100',
),
));
$this->add(array(
'name' => 'submit',
'type' => 'Submit',
'attributes' => array(
'value' => 'Login',
'id' => 'login',
'class'=>'btn btn-success',
),
));
}
}
and my controller action code is :
public function indexAction()
{
$form = new LoginForm();
$request = $this->getRequest();
$user=new LoginTable();
if ($request->isPost()) {
$login = new Login();
$form->setInputFilter($login->getInputFilter());
$form->setData($request->getPost());
if ($form->isValid()) {
$data=$login->exchangeArray($form->getData());
$user->getUser($this->$username,$this->$password);
if($user){
return $this->redirect()->toRoute('album', array(
'action' => 'album'));
}else{
return array('form' => $form);
}
}
}
return array('form' => $form);
}
my form is not validating at this statement "if ($form->isValid()){}" the exicution is not entering in this statement. I searched out every thing but not able to find solution what i m missing. Can any body help me to get out of this.
Looking at the form it looks as if you have an input filter attached to the hidden field id. If you are looking to register the user you obviously will not have their id before authentication.
You can test this by adding a else statement of your form and checking the forms messages (because the element is hidden you will not see it output otherwise)
if ($form->isValid()) {
// Is valid code here
} else {
print_r($form->getMessages());
}
This will probably output and array with the message "id - this element cannot be empty" or something similar.
The solution would be to remove the id input filter from the form (and probably the id form element as I can't see how this would be needed).
I try to add checkbox to my module config for PrestaShop 1.5. I use HelperForm as in manual but there is empty $helper->fields_value
public function getContent()
{
$output = null;
if (Tools::isSubmit('submit'.$this->name))
{
$fast_email = strval(Tools::getValue('fast_email'));
if (!$fast_email || empty($fast_email) || !Validate::isGenericName($fast_email))
$output .= $this->displayError( $this->l('Invalid Configuration value') );
else
{
Configuration::updateValue('fast_email', $fast_email);
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
$fast_email_sender = strval(Tools::getValue('fast_email_sender'));
if ( !Validate::isGenericName($fast_email_sender))
$output .= $this->displayError( $this->l('Invalid Configuration value') );
else
{
Configuration::updateValue('fast_email_sender', $fast_email_sender);
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
$fast_phone = strval(Tools::getValue('fast_phone'));
Configuration::updateValue('fast_phone', $fast_phone);
var_dump(Tools::getValue('fast_phone'));
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
return $output.$this->displayForm();
}
public function displayForm()
{
// Get default Language
$default_lang = (int)Configuration::get('PS_LANG_DEFAULT');
$options = array(
array(
'id_option' => 1, // The value of the 'value' attribute of the <option> tag.
'name' => 'email' // The value of the text content of the <option> tag.
),
array(
'id_option' => 2,
'name' => 'phone'
),
);
// var_dump($options);
// Init Fields form array
$fields_form[0]['form'] = array(
'legend' => array(
'title' => $this->l('Settings'),
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('admin email'),
'name' => 'fast_email',
'size' => 20,
'required' => true
)
,
array(
'type' => 'checkbox', // This is an <input type="checkbox"> tag.
'label' => $this->l('Options'), // The <label> for this <input> tag.
'desc' => $this->l('Choose options.'), // A help text, displayed right next to the <input> tag.
'name' => 'fast_phone', // The content of the 'id' attribute of the <input> tag.
'values' => array(
'query' => $options, // $options contains the data itself.
'id' => 'id_option', // The value of the 'id' key must be the same as the key for 'value' attribute of the <option> tag in each $options sub-array.
'name' => 'name' // The value of the 'name' key must be the same as the key for the text content of the <option> tag in each $options sub-array.
),
),
array(
'type' => 'radio',
'label' => $this->l('email'),
'name' => 'fast_email_sender', // The content of the 'id' attribute of the <input> tag.
'required' => true,
'class' => 't',
'values' => array( // $values contains the data itself.
array(
'id' => 'active_on', // The content of the 'id' attribute of the <input> tag, and of the 'for' attribute for the <label> tag.
'value' => 1, // The content of the 'value' attribute of the <input> tag.
'label' => $this->l('Enabled') // The <label> for this radio button.
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
),
)
),
'submit' => array(
'title' => $this->l('Save'),
'class' => 'button'
)
);
$helper = new HelperForm();
// Module, t oken and currentIndex
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
// Language
$helper->default_form_language = $default_lang;
$helper->allow_employee_form_lang = $default_lang;
// Title and toolbar
$helper->title = $this->displayName;
$helper->show_toolbar = true; // false -> remove toolbar
$helper->toolbar_scroll = true; // yes - > Toolbar is always visible on the top of the screen.
$helper->submit_action = 'submit'.$this->name;
$helper->toolbar_btn = array(
'save' =>
array(
'desc' => $this->l('Save'),
'href' => AdminController::$currentIndex.'&configure='.$this->name.'&save'.$this->name.
'&token='.Tools::getAdminTokenLite('AdminModules'),
),
'back' => array(
'href' => AdminController::$currentIndex.'&token='.Tools::getAdminTokenLite('AdminModules'),
'desc' => $this->l('Back to list')
)
);
// Load current value
$helper->fields_value['fast_email'] = Configuration::get('fast_email');
$helper->fields_value['fast_email_sender'] = Configuration::get('fast_email_sender');
$helper->fields_value['fast_phone'] = Configuration::get('fast_phone');
return $helper->generateForm($fields_form);
}
I add in install Configuration::updateValue('fast_phone','') when I checked it and save it doesn't update. I check config and it empty before and after submit
I know this theat is old but for others i give the solution :
According to documentation, the getContent method has to be written like that :
public function getContent()
{
$output = null;
// Save settings values
if (Tools::isSubmit('submit'.$this->name)) // Check if form is submitted
{
Configuration::updateValue('MODULE_OPTION1', Tools::getValue('MODULE_OPTION1'));
Configuration::updateValue('MODULE_OPTION2', Tools::getValue('MODULE_OPTION2'));
Configuration::updateValue('MODULE_OPTION3', Tools::getValue('MODULE_OPTION3'));
$output .= $this->displayConfirmation($this->l('Settings updated'));
}
return $output.$this->displayForm();
}
Of course it can be improved : checking values...