Как получить значение в чекбоксе Prestashop?

у меня есть функция renderForm

$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

Решение

Это отсутствует форма массив внутри 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');
1

Другие решения

Других решений пока нет …