Prestashop 1.7 renderform由admincontroller错误

时间:2018-11-06 10:17:07

标签: forms module controller prestashop helper

对于我的模块,我需要使用帮助程序生成一个表单。我在网上找不到任何与我的错误有关的信息,所以...我再次发布了一些内容...

这是我的AdminYoutubeHomeController

<?php


class AdminYoutubeHomeController extends ModuleAdminController
{
    public function __construct()
    {
        $this->bootstrap = true;
        $this->display = 'view';
        parent::__construct();
        $this->meta_title = $this->l('Youtube');
        if (!$this->module->active) {
            Tools::redirectAdmin($this->context->link->getAdminLink('AdminHome'));
        }
    }

    public function renderView()
    {
        /**
         * If values have been submitted in the form, process.
         */
        if (((bool)Tools::isSubmit('submitYoutubeHomeModule')) == true) {
            $this->postProcess();
        }

        $this->context->smarty->assign([
            'youtube_dir', _PS_MODULE_DIR_.'youtubehome',
            'youtube_embeded' => "https://www.youtube.com/embed/",
            'youtubeLink' => Configuration::get('YOUTUBEHOME_LINK_VIDEO')

        ]);

        return $this->context->smarty->fetch(_PS_MODULE_DIR_.'youtubehome/views/templates/admin/youtubehome.tpl').$this->renderForm();
    }

    /**
     * Create the form that will be displayed in the configuration of your module.
     */
    public function renderForm()
    {
        $helper = new HelperForm();

        $helper->show_toolbar = false;
        $helper->table = $this->table;
        $helper->module = $this;
        $helper->name_controller = $this->module->name;
        $helper->default_form_language = $this->context->language->id;
        $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG', 0);

        $helper->identifier = $this->identifier;
        $helper->submit_action = 'submitYoutubeHomeModule';

        $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false)
            .'&configure='.$this->module->name.'&tab_module='.$this->module->tab.'&module_name='.$this->module->name;
        $helper->token = Tools::getAdminTokenLite('AdminModules');

        $helper->tpl_vars = array(
            'fields_value' => $this->getConfigFormValues(), /* Add values for your inputs */
            'languages' => $this->context->controller->getLanguages(),
            'id_language' => $this->context->language->id,
        );

        return $helper->generateForm(array($this->getConfigForm()));
    }

    /**
     * Create the structure of your form.
     */
    public function getConfigForm()
    {
        return array(
            'form' => array(
                'legend' => array(
                    'title' => $this->l('Settings'),
                    'icon' => 'icon-cogs',
                ),
                'input' => array(
                    array(
                        'col' => 3,
                        'type' => 'text',
                        'prefix' => '<i class="icon icon-youtube-play"></i>',
                        'desc' => $this->l('Enter your youtube end link'),
                        'name' => 'YOUTUBEHOME_LINK_VIDEO',
                        'label' => $this->l('Link'),
                    ),
                ),
                'submit' => array(
                    'title' => $this->l('Save'),
                ),
            ),
        );
    }

    /**
     * Set values for the inputs.
     */
    public function getConfigFormValues()
    {
        return array(
            'YOUTUBEHOME_LINK_VIDEO' => Configuration::get('YOUTUBEHOME_LINK_VIDEO'),
        );
    }

    /**
     * Save form data.
     */
    public function postProcess()
    {
        $form_values = $this->getConfigFormValues();

        foreach (array_keys($form_values) as $key) {
            Configuration::updateValue($key, Tools::getValue($key));
        }
    }

}

这里是错误

enter image description here

我的tpl文件位于modules / youtubehome / views / templates / admin / youtubehome.tpl

我不想覆盖默认格式。你认为我做错了吗?

编辑帖子

这是ps_version的错误

enter image description here

1 个答案:

答案 0 :(得分:0)

尝试:

  sigma_points[:, [0]] = mu

致谢