2016-09-01 81 views
0

我有一個函數renderForm如何在複選框Prestashop中獲得價值?

$this->fields_form = array(
     'tinymce' => true, 
     'legend' => array(
      'title' => $this->l('Category'), 
      'icon' => 'icon-folder' 
     ), 
     'input' => array(

      array(
       'type' => 'checkbox', 
       'label' => $this->l('Group access'), 
       'name' => 'checkBox', 
       'values' => array(
        'query' => Group::getGroups($this->id_lang), 
        'id' => 'id_group', 
        'name' => 'name' 
       ), 
       'unidentified' => $unidentified_group_information, 
       'guest' => $guest_group_information, 
       'customer' => $default_group_information, 
       'info_introduction' => $this->l('You now have three default customer groups.'), 
       'hint' => $this->l('Mark all of the customer groups which you would like to have access to this category.') 
      ) 
     ), 
     'submit' => array(
      'title' => $this->l('Save'), 
      'class' => 'btn btn-large btn-success pull-right' 
     ) 
    ); 

我需要插入獲取複選框的值到數據庫

print_r($_POST) IT展checkBox_1 =>上,checkBox_2 =>在

此類擴展ModuleAdminController

+0

它使用的版本prestashop? –

+0

嗨馬泰奧。我用1.6 –

回答

0

它缺少一個的形式數組fields_form。的Prestashop renderForm正確的結構必須是:

$fields_form = array(
    'form' => array(
     'tinymce' => true, 
     'legend' => array(...), 
     'input' => array(...), 
     'submit' => array(...) 
    ) 
) 

一個print_r($_POST)將輸出類似:

Array (
    [Form_id] => 1 
    [form_id] => Form_id 
    [checkBox] => 1 
    [tab] => AdminModules 
) 

要獲得該複選框值(S):

$checkBoxValues = Tools::getValue('checkBox');