donglan6967 2015-05-27 00:58
浏览 52
已采纳

Prestashop 1.6模块错误:文件prestashop16 \ tools \ smarty \ sysplugins \ smarty_internal_templatebase.php中第719行的注意事项

I'm developing a module and extended AdminFeaturesController.php to display my custom field Add/Edit Feature Value, but it is showing following error in popup:

Notice on line 719 in file D:\xampp\htdocs\prestashop16\tools\smarty\sysplugins\smarty_internal_templatebase.php(157) : eval()'d code [8] Undefined index: value

I think it is due to I override the function initFormFeatureValue() in my AdminFeaturesController.php file and added a new field. Here is the code for that:

public function initFormFeatureValue()
    {
        $this->setTypeValue();

        $this->fields_form[0]['form'] = array(
            'legend' => array(
                'title' => $this->l('Feature value'),
                'icon' => 'icon-info-sign'
            ),
            'input' => array(
                array(
                    'type' => 'select',
                    'label' => $this->l('Feature'),
                    'name' => 'id_feature',
                    'options' => array(
                        'query' => Feature::getFeatures($this->context->language->id),
                        'id' => 'id_feature',
                        'name' => 'name'
                    ),
                    'required' => true
                ),
                array(
                    'type' => 'text',
                    'label' => $this->l('Value'),
                    'name' => 'value',
                    'lang' => true,
                    'size' => 33,
                    'hint' => $this->l('Invalid characters:').' <>;=#{}',
                    'required' => true
                ),
                array(
                    'type' => 'select',
                    'label' => $this->l('Parent Feature Value'),
                    'name' => 'parent_id_feature_value',
                    'options' => array(
                        'query' => FeatureValue::getFeatureValues((int)Tools::getValue('id_feature')),
                        'id' => 'id_feature_value',
                        'name' => 'value'
                    ),
                    'required' => true
                ),
            ),
            'submit' => array(
                'title' => $this->l('Save'),
            ),
            'buttons' => array(
                'save-and-stay' => array(
                    'title' => $this->l('Save then add another value mamu'),
                    'name' => 'submitAdd'.$this->table.'AndStay',
                    'type' => 'submit',
                    'class' => 'btn btn-default pull-right',
                    'icon' => 'process-icon-save'
                )
            )
        );

        $this->fields_value['id_feature'] = (int)Tools::getValue('id_feature');

        // Create Object FeatureValue
        $feature_value = new FeatureValue(Tools::getValue('id_feature_value'));

        $this->tpl_vars = array(
            'feature_value' => $feature_value,
        );

        $this->getlanguages();
        $helper = new HelperForm();
        $helper->show_cancel_button = true;

        $back = Tools::safeOutput(Tools::getValue('back', ''));
        if (empty($back))
            $back = self::$currentIndex.'&token='.$this->token;
        if (!Validate::isCleanHtml($back))
            die(Tools::displayError());

        $helper->back_url = $back;
        $helper->currentIndex = self::$currentIndex;
        $helper->token = $this->token;
        $helper->table = $this->table;
        $helper->identifier = $this->identifier;
        $helper->override_folder = 'feature_value/';
        $helper->id = $feature_value->id;
        $helper->toolbar_scroll = false;
        $helper->tpl_vars = $this->tpl_vars;
        $helper->languages = $this->_languages;
        $helper->default_form_language = $this->default_form_language;
        $helper->allow_employee_form_lang = $this->allow_employee_form_lang;
        $helper->fields_value = $this->getFieldsValue($feature_value);
        $helper->toolbar_btn = $this->toolbar_btn;
        $helper->title = $this->l('Add a new feature value');
        $this->content .= $helper->generateForm($this->fields_form);
    }

Any idea why it is showing this error? Also, it is not populating my custom field.

  • 写回答

1条回答 默认 最新

  • duanmin0941 2015-05-27 01:53
    关注

    OK, I fixed it. The problem was with options array in my new field array. Following is the correct one.

    array(
                    'type' => 'select',
                    'label' => $this->l('Parent Feature Value'),
                    'name' => 'parent_id_feature_value',
                    'options' => array(
                        'query' => FeatureValue::getFeatureValuesWithLang($this->context->language->id, $parent_id),
                        'id' => 'id_feature_value',
                        'name' => 'value'
                    ),
                    'required' => true
                ),
    

    Here I had to override the FeatureValue class and add the getFeatureValuesWithLang() function.

    public static function getFeatureValuesWithLang($id_lang, $id_feature, $custom = false)
    {
        return Db::getInstance()->executeS('
            SELECT *
            FROM `'._DB_PREFIX_.'feature_value` v
            LEFT JOIN `'._DB_PREFIX_.'feature_value_lang` vl
                ON (v.`id_feature_value` = vl.`id_feature_value` AND vl.`id_lang` = '.(int)$id_lang.')
            WHERE v.`id_feature` = '.(int)$id_feature.'
                '.(!$custom ? 'AND (v.`custom` IS NULL OR v.`custom` = 0)' : '').'
            ORDER BY v.`position` ASC
        ', true, false);
    }
    

    What is actually does is that it was finding the 'value' field which was not present in the query result. So, I override FeatureValue class and add the above method and called that one. It solved the problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog