Jump to content

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


Recommended Posts

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 : 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)
Link to comment
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...