Hi guys, I'm new on Prestashop and i am facing a problem. I want to add new tab in products back office and save data from form into a new tab. I display easily all things but now i fail to insert data from helper form into a new table that i created at the install of this module. Please help me ! Regards EDIT :
public function hookdisplayAdminProductsExtra() {
if (Validate::isLoadedObject($product = new Product((int) Tools::getValue('id_product')))) {
return $this->renderForm().process();
}
}
function renderForm() {
$guarantees = 'SELECT * FROM ' . _DB_PREFIX_ . 'guarantee';
$guarantees = Db::getInstance()->ExecuteS($guarantees);
$guarantee_iteration = 0;
foreach ($guarantees as $guarantee) {
$guarantees[$guarantee_iteration]['nameselect'] = $guarantee['id_guarantee'] . ' - ' . $guarantee['name'] . ' - ' . $guarantee['type'];
$guarantee_iteration++;
}
$fields_form_1 = array(
'form' => array(
'legend' => array(
'title' => 'Choix de la garantie produit',
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'select',
'name' => 'PS_GUARANTEE_SELECT',
'label' => 'Liste des garanties :',
'required' => true,
'hint' => 'Liste des garanties existante',
'options' => array(
'query' => $guarantees,
'name' => 'nameselect',
'id' => 'id_guarantee')
),
),
'submit' => array(
'title' => 'Enregistrer',
'class' => 'btn btn-default',
'name' => 'submitEditExtraTab'
)
)
);
$helper = new HelperForm();
$helper->show_toolbar = false;
$helper->table = $this->name;
$helper->module = $this;
$helper->identifier = $this->identifier;
$helper->submit_action = 'submitEditExtraTab';
$helper->currentIndex = $this->context->link->getAdminLink('AdminProducts', false);
$helper->token = Tools::getAdminTokenLite('AdminProducts');
$helper->toolbar_btn = array(
'save' =>
array(
'short' => 'Sauv',
'desc' => 'Enregistrer'
),
);
return $helper->generateForm(array($fields_form_1));
}
public function process() {
$id_product = (Tools::getValue('id_product'));
//Some stuff
if (Tools::isSubmit('submitEditExtraTab')) {
//Here it's not working
}
}