2016-09-01 6 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) это показать checkBox_1 => на, checkBox_2 => на

этот класс расширяет ModuleAdminController

+0

, который использует версию prestashop? –

+0

Привет Matteo. Я использую 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 
) 

Чтобы получить значение флажок (ы):

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