PrestashopUser03 Posted May 30, 2022 Share Posted May 30, 2022 Bonjour, Je développe un module ayant une structure many to many de ce type: Table A Table B Table de liaison A-B. Comment faire pour que les checkbox des fields_form des controller A et B soient enregistrées dans la table de liaison A-B ? Link to comment Share on other sites More sharing options...
PrestashopUser03 Posted May 31, 2022 Author Share Posted May 31, 2022 (edited) Up : Voici mon admin controller actuellement : <?php require_once _PS_MODULE_DIR_ . 'monmodule/classes/TypeValue.php'; require_once _PS_MODULE_DIR_ . 'monmodule/classes/Type.php'; class AdminHBATypeValueController extends ModuleAdminController { public function __construct(){ parent::__construct(); // Base $this->bootstrap = true; // use Bootstrap CSS $this->table = 'hba_type_value'; // SQL table name, will be prefixed with _DB_PREFIX_ $this->identifier = 'id_type_value'; // SQL column to be used as primary key $this->className = 'TypeValue'; // PHP class name $this->allow_export = true; // allow export in CSV, XLS.. $this->_defaultOrderBy = 'id_type_value'; // the table alias is always `a` $this->_select='a.nom as `tvNom`, t.nom as tNom'; $this->_join=' LEFT JOIN `'._DB_PREFIX_.'hba_type` t ON (t.id_type=a.type_id)'; $this->fields_list = [ 'id_type_value' => ['title' => 'ID','class' => 'fixed-width-xs'], 'tNom'=>['title'=>'Type d\'abonnement'], 'tvNom' => ['title' => 'Valeur'], ]; $this->addRowAction('edit'); $this->addRowAction('delete'); $type_dabo=Type::getTypes(); $this->fields_form = [ 'legend' => [ 'title' => 'Valeur des types d\'abonnements', 'icon' => 'icon-list-ul' ], 'input' => [ ['name'=>'type_id', 'label'=>'Sélectionnez le type d\'abonnement','type'=>'checkbox', 'required'=>true, 'values'=>['query'=>$type_dabo, 'id'=>'id_type', 'name'=>'nom', ]], ['name'=>'nom','type'=>'text','label'=>'Nom de la valeur','required'=>true], ], 'submit' => [ 'title' => $this->trans('Save', [], 'Admin.Actions'), ] ]; dump($this->fields_form); } } J'arrive bien à générer un formulaire de ce type : Mais comment faire pour récupérer les informations passées dans le formulaire avant l'insertion en base de données afin que je puisse les traiter moi même ? Edited May 31, 2022 by PrestashopUser03 (see edit history) 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