【问题标题】:Prestashop User group 'group' form helper in custom module自定义模块中的 Prestashop 用户组“组”表单助手
【发布时间】:2020-04-14 02:37:53
【问题描述】:

我希望通过辅助方法在我的模块中使用客户组组件(我在 AdminPattern 控制器中找到它)。我可以将选中的复选框保存到配置表(我序列化数组并将选项另存为文本),但无法将保存的值加载回表单。

    array(
                    'type' => 'group',
                    'label' => 'group',
                    'name' => 'configuration[]',
                    'values' => Group::getGroups(Context::getContext()->language->id),
                ),

后期处理中:

if (Tools::isSubmit('submitTallerOrden'))
    {
        $_POST['configuration'] = implode(',', Tools::getValue('configuration'));
    }

呈现形式我有:

$this->fields_value['configuration[]'] = explode(',',$obj->configuration);

【问题讨论】:

    标签: forms prestashop helper form-helpers


    【解决方案1】:

    喜欢 AdminCustomersController

    形式:

                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.')
                ),
    

    在渲染表单中:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      • 2019-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多