Jump to content

Développement de module - checkbox et structure de table many to many

Recommended Posts


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 ?



Share this post

Link to post
Share on other sites

Posted (edited)

Up : Voici mon admin controller actuellement



 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(){
    // 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->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,

        ['name'=>'nom','type'=>'text','label'=>'Nom de la valeur','required'=>true],
      'submit' => [
        'title' => $this->trans('Save', [], 'Admin.Actions'),




J'arrive bien à générer un formulaire de ce type : image.png


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 by PrestashopUser03 (see edit history)

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More