Jump to content

nozzula

Members
  • Posts

    15
  • Joined

  • Last visited

Profile Information

  • Activity
    Developer

nozzula's Achievements

Newbie

Newbie (1/14)

2

Reputation

  1. Adding an array 'submit' in fields_options (I don't know why but) everything works fine. Here's the final code: Thank you guys public function getContent() { if (Tools::isSubmit('submitOptionsconfiguration')) { $PS_MYMODULE_OPTION1 = Tools::getValue('PS_MYMODULE_OPTION1'); Configuration::updateValue('PS_MYMODULE_OPTION1', $PS_MYMODULE_OPTION1); } return $this->displayForm(); } public function displayForm() { $fields_options = array( 'general' => array( 'title' => $this->l('Parameters'), 'image' => '../img/admin/information.png', 'fields' => array( 'PS_MYMODULE_OPTION1' => array( 'title' => $this->l('Choose one'), 'desc' => $this->l('Choose between Yes and No.'), 'cast' => 'boolval', 'type' => 'bool', ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ), ) ); $helper = new HelperOptions(); $helper->module = $this; $helper->id=$this->id; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->title = $this->displayName; $helper->show_toolbar = true; $helper->toolbar_scroll = true; $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') ) ); return $helper->generateOptions($fields_options); }
  2. I removed the second option (PS_MYMODULE_OPTION2), anyway still not work. I noticed that: the method generateOptions() create a form POST without the submit button... And the save button inserted in the toolbar submit as GET request. I guess there's something wrong in this and the problem is there...
  3. modified in $PS_MYMODULE_OPTION1 = Tools::getValue('PS_MYMODULE_OPTION1'); $PS_MYMODULE_OPTION2 = Tools::getValue('PS_MYMODULE_OPTION2'); die('test=#' . $PS_MYMODULE_OPTION1 . '#' . $PS_MYMODULE_OPTION2 . '#'); still got empty value from getValue "test=###"
  4. Looking in the class code HelperOptions.php, the method $helper->generateOptions($fields_options) use the file admin6157\themes\default\template\helpers\options.tpl as template. This template already contains a form, infact the final html code that I get is <form action="index.php?controller=AdminModules&configure=mymodule&token=986f54fc864f06d2779e8674cc589bea" id="configuration_form" method="post" enctype="multipart/form-data"> <fieldset > [...] <input type="radio" name="PS_MYMODULE_OPTION1" id="PS_MYMODULE_OPTION1_on" value="1" /> <input type="radio" name="PS_MYMODULE_OPTION1" id="PS_MYMODULE_OPTION1_off" value="0" checked="checked"/> [...] I don't think I need to use even a fields_form, do you?
  5. Hi, I do not figured out how to use the HelperOptions class to configure a module. In my module main class I've declared the following functions, but when I click on save button, the die function return "test=###" So the Tools::getValue() doesn't return any value What's wrong with it? public function getContent() { if (Tools::isSubmit('save'.$this->name)) { $id_PS_MYMODULE_OPTION1 = Tools::getValue('id_PS_MYMODULE_OPTION1'); $id_PS_MYMODULE_OPTION2 = Tools::getValue('id_PS_MYMODULE_OPTION2'); die('test=#' . $id_PS_MYMODULE_OPTION1 . '#' . $id_PS_MYMODULE_OPTION2 . '#'); Configuration::updateValue('PS_MYMODULE_OPTION1', $id_PS_MYMODULE_OPTION1); Configuration::updateValue('PS_MYMODULE_OPTION2', $id_PS_MYMODULE_OPTION2); } return $this->displayForm(); } public function displayForm() { $fields_options = array( 'general' => array( 'title' => $this->l('Parameters'), 'fields' => array( 'PS_MYMODULE_OPTION1' => array( 'title' => $this->l('Choose one'), 'desc' => $this->l('Choose between Yes and No.'), 'cast' => 'boolval', 'type' => 'bool', 'identifier' => 'id_PS_MYMODULE_OPTION1', ), 'PS_MYMODULE_OPTION2' => array( 'title' => $this->l('Add some text'), 'desc' => $this->l('This is where you can add some text'), 'cast' => 'strval', 'type' => 'text', 'size' => '10', 'identifier' => 'id_PS_MYMODULE_OPTION2', ), ) ) ); $helper = new HelperOptions(); $helper->module = $this; $helper->id=$this->id; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->title = $this->displayName; $helper->show_toolbar = true; $helper->toolbar_scroll = true; $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') ) ); return $helper->generateOptions($fields_options); }
  6. Solved using $this->module->l('A visitor', 'display'); where 'display' is my front controller
  7. It seems that we can't use the l() function inside of an extended ModuleFrontController() $label = ($this->context->cookie->logged ? $this->context->cookie->customer_firstname.' '.$this->context->cookie->customer_lastname : $this->l('A visitor')); I got this error: Fatal error: Call to undefined method mymoduledisplayModuleFrontController::l() in Any advice would be greatly appreciated.
  8. Hi, I generated a backoffice page with HelperList $this->fields_list = array .... bla bla bla ... Now I'd like to disable the edit function. How can I do? cheers
  9. ok I created {prestashop-dir}\modules\{mymodule-dir}\views\templates\admin\my_module\helpers\form\form.tpl form.tpl contains: {extends file="helpers/form/form.tpl"} this is my custom text but after the module installation still not work...what's wrong?
  10. Hi, I'm developing a module for 1.5 that adds a new tab in the administration pages. Here my class class MyModuleController extends ModuleAdminController { [...] public function init() { parent::init(); [...] $this->fields_list = array( 'myID' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 30 ), 'myText' => array( 'title' => $this->l('Status'), 'align' =>'center', 'width' => 90, 'type' => 'select', 'list' => $statusArray, 'filter_key' => 's!id_status' ) ); } public function renderForm() { [...] $this->fields_form = array( 'legend' => array( 'title' => $this->l('myTitle'), 'image' => '../modules/mymodule/img/logo.gif' ), 'input' => array( array( 'type' => 'select', 'label' => $this->l('Customer'), 'name' => 'id_customer', 'default_value' => (int)$cust_select->id, 'options' => array( 'query' => $customers, 'id' => 'id_customer', 'name' => 'lastname' ), ), array( 'type' => 'select', 'label' => $this->l('Status'), 'name' => 'id_status', 'default_value' => (int)$obj->id_status, 'hint' => $this->l('The status change automatically depending on customer s choice, modify it exceptionally!'), 'options' => array( 'query' => $status_lang, 'id' => 'id_status', 'name' => 'status_desc' ), ), ), 'submit' => array( 'title' => $this->l('Save'), 'class' => 'button' ) ); return parent::renderForm(); } } I'd like to customize the (helpers) form.tpl and list.tpl and the form.tpl used in the module configuration page. Which is the right path to place the custom tpl in my module dir? I tried with {prestashop-dir}\modules\{mymodule}\views\templates\admin\helpers\form\form.tpl {prestashop-dir}/modules/{mymodule}/views/templates/admin/{controller}/helpers/form/form.tpl but not work...
  11. Hi, may I ask you which is the right path to place the custom form.tpl? I tried with {prestashop-dir}\modules\{mymodule}\views\templates\admin\helpers\form\ but is not work...
  12. Hi, here a solution is proposed by Jeff (see comments)
×
×
  • Create New...