简体   繁体   中英

Prestashop User group 'group' form helper in custom module

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));
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM