Benoit.ndr Posted February 4, 2016 Share Posted February 4, 2016 Hey there !I'm creating a prestashop module for my company.I'm using helpers to do a clean job.The problem is with my renderForm ! When I try to edit a row, only the id_product field is getting the value, not the 3 others..So I'd like to understand why ?Thanks guys :/ /* Constructeur */ public function __construct() { $this->bootstrap = true; /* Pour aller chercher la table correspondante dans la base */ $this->table = 'reverdy_aliments'; $this->className = 'ReverdyPrices'; $this->deleted = false; $this->context = Context::getContext(); /* Pour ajouter la checkbox à gauche */ /*$this->bulk_actions = array( 'delete' => array( 'text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash' ) );*/ /* Pour préciser que la clé primaire n'est pas 'id_'.$table */ $this->identifier = 'id_product'; parent::__construct(); } /* Pour ajouter les boutons */ public function renderList() { /* Boutons sur les lignes du tableau */ $this->addRowAction('edit'); /* Champs voulus dans le tableau */ $this->fields_list = array( 'id_product' => array( 'title' => $this->l('Produit'), 'align' => 'center', 'callback' => 'getAlimentNameById' ), 'departement' => array( 'title' => $this->l('Département'), 'align' => 'center' ), 'quantite_kg' => array( 'title' => $this->l('Quantité'), 'align' => 'center' ), 'prix_ht' => array( 'title' => $this->l('Prix H.T.'), 'align' => 'center' ) ); return parent::renderList(); } /* Pour récupérer directement le nom des produits */ public function getAlimentNameById($echo,$row) { $id_product = (int)$row['id_product']; if($id_product){ $produit = new Product($id_product); return $produit->name[$this->context->language->id]; } return ""; } /* Pour le formulaire de modification */ public function renderForm() { if (!($obj = $this->loadObject(true))) return; $this->fields_form = array( 'tinymce'=> false, 'legend' => array( 'title' => $this->l('Produit'), 'icon' => 'icon-cogs', ), 'input' => array( array( 'type' => 'text', 'name' => 'id_product', 'label' => $this->l('Produit'), 'disabled' => true ), array( 'type' => 'text', 'name' => 'departement', 'label' => $this->l('Département'), 'disabled' => true ), array( 'type' => 'text', 'name' => 'quantite_kg', 'label' => $this->l('Quantité en kg'), 'disabled' => true ), array( 'type' => 'text', 'name' => 'prix_ht', 'label' => $this->l('Prix H.T.') ) ), 'submit' => array( 'title' => $this->l('Save'), 'name' => 'submitAdd'.$this->table ) ); /*$this->fields_value = array('departement' => 'test'); $this->fields_value['id_employee_default'] = $default_employee;*/ return parent::renderForm(); } 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