I wanto to use Customer group componnet (I find it in AdminPattern controller) in my module in from helper method. I can save checked checkboxes to configuration table (I serialized array and save options as text) but cant load saved values back to form.
array(
'type' => 'group',
'label' => 'group',
'name' => 'configuration[]',
'values' => Group::getGroups(Context::getContext()->language->id),
),
In post process:
if (Tools::isSubmit('submitTallerOrden'))
{
$_POST['configuration'] = implode(',', Tools::getValue('configuration'));
}
in render form I have:
$this->fields_value['configuration[]'] = explode(',',$obj->configuration);
Like AdminCustomersController
in form:
array(
'type' => 'group',
'label' => $this->l('Group access'),
'name' => 'groupBox',
'values' => Group::getGroups($this->default_form_language, true),
'required' => true,
'col' => '6',
'hint' => $this->l('Select all the groups that you would like to apply to this customer.')
),
in renderForm:
foreach ($groups as $group) {
$this->fields_value['groupBox_'.$group['id_group']] =
Tools::getValue('groupBox_'.$group['id_group'], in_array($group['id_group'], $customer_groups_ids));
}