parsa Posted December 27, 2018 Share Posted December 27, 2018 I made a module to hook a form in product page in the back office (with hook DisplayAdminProductExtra). I'm the newbie in Prestashop so I have a simple question: How can I create a form with some inputs by module? Believe me, I'm not a lazy person, I searched the whole internet for a couple of days and I couldn't find the answer 😞 I think it can be done by {helper and .tpl file} or {form_field and .twig file}. If anyone explains this as a walkthrough I'm sure it's gonna be a good reference for many others too. I already appreciated for your time. this is the code that created by PrestaShop module generator: <?php if (!defined('_PS_VERSION_')) { exit; } class Myfirstmodule extends Module { public function __construct() { $this->name = 'myfirstmodule'; $this->tab = 'administration'; $this->version = '1.0.0'; $this->author = 'parsa'; $this->need_instance = 0; $this->bootstrap = true; parent::__construct(); $this->displayName = $this->l('new module'); $this->description = $this->l('first module'); $this->confirmUninstall = $this->l('Are you sure?'); $this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_); } public function install() { Configuration::updateValue('MYFIRSTMODULE_LIVE_MODE', false); return parent::install() && $this->registerHook('displayAdminProductsExtra'); } public function uninstall() { Configuration::deleteByName('MYFIRSTMODULE_LIVE_MODE'); return parent::uninstall(); } public function hookDisplayAdminProductsExtra() { /* Place your code here. */ } } Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted December 28, 2018 Share Posted December 28, 2018 (edited) Hi.. you have right way about "displayAdminProductsExtra" call the your module file this hook like this public function hookDisplayAdminProductsExtra($params) { return $this->context->smarty->fetch($this->local_path . 'views/templates/hook/displayAdminProductsExtra.tpl');//this is path of your module display file } and "displayAdminProductsExtra.tpl" file somthing your html code <input type="text" name="input" value="demo" /> about save the this fields use this hook "actionProductUpdate" public function hookActionProductUpdate($params) { $id_product = $params['id_product']; /// your custom code here } Thanks Edited December 28, 2018 by Nishith (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now