NaveenYadav Posted May 23, 2013 Share Posted May 23, 2013 Hello, I want to create form using helper class. I am creating a module which is making a Admin tab when I am click on this tab it will redirect to the corresponding controller,on this controller I extends AdminTab class . Admin class have a function display in which our content show but my question is if we create form manually then it will created but I want to create form in this using helper class. So please help me Note : I have been created form using helper class but by extending Module class . Thanks Link to comment Share on other sites More sharing options...
NaveenYadav Posted May 24, 2013 Author Share Posted May 24, 2013 Is Any one here. Link to comment Share on other sites More sharing options...
SmartDataSoft Posted May 24, 2013 Share Posted May 24, 2013 Hello, I want to create form using helper class. I am creating a module which is making a Admin tab when I am click on this tab it will redirect to the corresponding controller,on this controller I extends AdminTab class . Admin class have a function display in which our content show but my question is if we create form manually then it will created but I want to create form in this using helper class. So please help me Note : I have been created form using helper class but by extending Module class . Thanks i suggest you to view editorial module which is prestashop code module. here is the code from there and it will help you to build form using form class. private function initForm() { $languages = Language::getLanguages(false); foreach ($languages as $k => $language) $languages[$k]['is_default'] = (int)($language['id_lang'] == Configuration::get('PS_LANG_DEFAULT')); $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = 'editorial'; $helper->identifier = $this->identifier; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->languages = $languages; $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->default_form_language = (int)Configuration::get('PS_LANG_DEFAULT'); $helper->allow_employee_form_lang = true; $helper->toolbar_scroll = true; $helper->toolbar_btn = $this->initToolbar(); $helper->title = $this->displayName; $helper->submit_action = 'submitUpdateEditorial'; $this->fields_form[0]['form'] = array( 'tinymce' => true, 'legend' => array( 'title' => $this->displayName, 'image' => $this->_path.'logo.gif' ), 'submit' => array( 'name' => 'submitUpdateEditorial', 'title' => $this->l('Save '), 'class' => 'button' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Main title'), 'name' => 'body_title', 'lang' => true, 'size' => 64, 'hint' => $this->l('Appears along top of your homepage'), ), array( 'type' => 'text', 'label' => $this->l('Subheading'), 'name' => 'body_subheading', 'lang' => true, 'size' => 64, ), array( 'type' => 'textarea', 'label' => $this->l('Introductory text'), 'name' => 'body_paragraph', 'lang' => true, 'autoload_rte' => true, 'hint' => $this->l('For example... explain your mission, highlight a new product, or describe a recent event.'), 'cols' => 60, 'rows' => 30 ), array( 'type' => 'file', 'label' => $this->l('Homepage logo'), 'name' => 'body_homepage_logo', 'display_image' => true ), array( 'type' => 'text', 'label' => $this->l('Homepage logo link'), 'name' => 'body_home_logo_link', 'size' => 33, ), array( 'type' => 'text', 'label' => $this->l('Homepage logo subheading'), 'name' => 'body_logo_subheading', 'lang' => true, 'size' => 33, ), ) ); return $helper; } Link to comment Share on other sites More sharing options...
NaveenYadav Posted May 24, 2013 Author Share Posted May 24, 2013 I try this but it give this errror. Fatal error: Call to undefined method category::addJS() in /home/sparxmgnt/public-html/Presta_Google/classes/helper/HelperForm.php on line 74 Link to comment Share on other sites More sharing options...
SmartDataSoft Posted May 24, 2013 Share Posted May 24, 2013 I try this but it give this errror. Fatal error: Call to undefined method category::addJS() in /home/sparxmgnt/public-html/Presta_Google/classes/helper/HelperForm.php on line 74 see the error happen to addJs call you try to add a non declare class did you initialize the object like category = new Category(); or Category::.. as the class name is Category not small later category. Please check again. Link to comment Share on other sites More sharing options...
NaveenYadav Posted May 24, 2013 Author Share Posted May 24, 2013 Here is my code ,please check <?php class category extends AdminTab { public function __construct(){ global $cookie; $cont = 'category'; $tkn = Tools::getValue('token'); $this->url ='index.php?controller='.$cont.'&token='.$tkn; parent::__construct(); } private function initForm() { $languages = Language::getLanguages(false); foreach ($languages as $k => $language) $languages[$k]['is_default'] = (int)($language['id_lang'] == Configuration::get('PS_LANG_DEFAULT')); $helper = new HelperForm(); $helper->module = $this; $helper->name_controller = 'category'; $helper->identifier = $this->identifier; $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->languages = $languages; $helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name; $helper->default_form_language = (int)Configuration::get('PS_LANG_DEFAULT'); $helper->allow_employee_form_lang = true; $helper->toolbar_scroll = true; $helper->toolbar_btn = $this->initToolbar(); $helper->title = $this->displayName; $helper->submit_action = 'submitUpdateEditorial'; $this->fields_form[0]['form'] = array( 'tinymce' => true, 'legend' => array( 'title' => $this->displayName, 'image' => $this->_path.'logo.gif' ), 'submit' => array( Here is my code ,please check category is 'name' => 'submitUpdateEditorial', 'title' => $this->l(' Save '), 'class' => 'button' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Main title'), 'name' => 'body_title', 'lang' => true, 'size' => 64, 'hint' => $this->l('Appears along top of homepage'), ), array( 'type' => 'text', 'label' => $this->l('Subheading'), 'name' => 'body_subheading', 'lang' => true, 'size' => 64, ), array( 'type' => 'textarea', 'label' => $this->l('Introductory text'), 'name' => 'body_paragraph', 'lang' => true, 'autoload_rte' => true, 'hint' => $this->l('Text of your choice; for example, explain your mission, highlight a new product, or describe a recent event.'), 'cols' => 60, 'rows' => 30 ), array( 'type' => 'file', 'label' => $this->l('Homepage logo'), 'name' => 'body_homepage_logo', 'display_image' => true ), array( 'type' => 'text', 'label' => $this->l('Homepage logo link'), 'name' => 'body_home_logo_link', 'size' => 33, ), array( 'type' => 'text', 'label' => $this->l('Homepage logo subheading'), 'name' => 'body_logo_subheading', 'lang' => true, 'size' => 33, ), ) ); return $helper; } private function initToolbar() { $this->toolbar_btn['save'] = array( 'href' => '#', 'desc' => $this->l('Save') ); return $this->toolbar_btn; } public function display() { $helper = $this->initForm(); $a = $helper->generateForm($this->fields_form); echo $a; } } ?> Link to comment Share on other sites More sharing options...
GS VISION Posted July 29, 2014 Share Posted July 29, 2014 I tested the code and it looks fine, also it does not have the addJS function that makes the error Link to comment Share on other sites More sharing options...
devzinga Posted June 17, 2015 Share Posted June 17, 2015 I think this is something that you are looking for: http://doc.prestashop.com/display/PS15/Using+helpers+to+overload+a+back-office+template I went thru documentation, helper class was introducted in prestashop 1.5 and used in 1.6 as well using this, you can view form and list. I am trying to figure out how to add data now. Link to comment Share on other sites More sharing options...
ZHSoft Posted January 6, 2021 Share Posted January 6, 2021 https://devdocs.prestashop.com/1.7/modules/concepts/forms/admin-forms/ Alter configuration forms on modern pages1.7.4 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