tartofraiz Posted February 3, 2017 Share Posted February 3, 2017 Hi i'm new to prestashop and i try to create an admin module to 1.7. My installation is complete, my module create a new tab with a controller and a template. My new objectif is to create a table ot list my content and create an "add button" with a form. Here my module controller : class MyModuleController extends ModuleAdminController{ public function renderList() { // Define associated model $this->table = 'MyModule'; $this->className = 'MyModule'; $this->allow_export = true; $this->addRowAction('view'); $this->addRowAction('add'); $this->addRowAction('edit'); $this->addRowAction('delete'); $this->content = $this->createTemplate('mymodule.tpl')->fetch(); return parent::renderList(); } public function initProcess() { if (Tools::isSubmit('add'.$this->table.'root')) { if ($this->access('add')) { $this->action = 'add'.$this->table.'root'; $obj = $this->loadObject(true); if (Validate::isLoadedObject($obj)) { $this->display = 'edit'; } else { $this->display = 'add'; } } else { $this->errors[] = $this->trans('You do not have permission to edit this.', array(), 'Admin.Notifications.Error'); } } parent::initProcess(); } public function initPageHeaderToolbar() { if (empty($this->display)) { $this->page_header_toolbar_btn['new_supplier'] = array( 'href' => self::$currentIndex.'&addMyModule&token='.$this->token, 'desc' => $this->trans('Ajout commande', array(), 'Admin.Catalog.Feature'), 'icon' => 'process-icon-new' ); } parent::initPageHeaderToolbar(); } public function renderForm() { $tmp_addr = new Address(); $res = $tmp_addr->getFieldsRequiredDatabase(); $required_fields = array(); foreach ($res as $row) { $required_fields[(int)$row['id_required_field']] = $row['field_name']; } $this->fields_form = array( 'legend' => array( 'title' => 'creation nouvelle commande fournisseurs', 'icon' => 'icon-truck' ), 'input' => array( array( 'type' => 'text', 'label' => $this->trans('Name', array(), 'Admin.Global'), 'name' => 'name', 'required' => true, 'col' => 4, 'hint' => $this->trans('Invalid characters:', array(), 'Admin.Notifications.Info').' <>;=#{}', ), array( 'type' => 'textarea', 'label' => $this->trans('Description', array(), 'Admin.Global'), 'name' => 'description', 'lang' => true, 'hint' => array( $this->trans('Invalid characters:', array(), 'Admin.Notifications.Info').' <>;=#{}', $this->trans('Will appear in the list of suppliers.', array(), 'Admin.Catalog.Help') ), 'autoload_rte' => 'rte' //Enable TinyMCE editor for short description ), array( 'type' => 'text', 'label' => $this->trans('Phone', array(), 'Admin.Global'), 'name' => 'phone', 'required' => in_array('phone', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->trans('Phone number for this supplier', array(), 'Admin.Catalog.Help') ), array( 'type' => 'select', 'label' => $this->trans('Suppliers', array(), 'Admin.Global'), 'name' => 'id_country', 'required' => true, 'col' => 4, 'default_value' => (int)$this->context->country->id, 'options' => array( 'query' => Supplier::getSuppliers($this->context->language->id, false), 'id' => 'id_suppliers', 'name' => 'Suppliers', ), ) ), 'submit' => array( 'title' => $this->trans('Save', array(), 'Admin.Actions'), ) ); if (Shop::isFeatureActive()) { $this->fields_form['input'][] = array( 'type' => 'shop', 'label' => $this->trans('Shop association', array(), 'Admin.Global'), 'name' => 'checkBoxShopAsso', ); } return parent::renderForm(); } public function postProcess() { return parent::postProcess(); }} Here my tpl : <section > <div>Hello world !</div> </section> I used the documentation to build my "first module" and had look at several native module to display my content. but when i click on the button "ajout commande" my "render_form" didn't display, the "hello world" remain. I'm a beginner so excuse me if my question is stupid but ... how display my content ? 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