编程语言
首页 > 编程语言> > php – 未提交评论表单

php – 未提交评论表单

作者:互联网

在我的项目中,我在管理面板的“产品评论”中添加了一个新的字段位置,按照许多博客中的说明执行以下步骤.

>在数据库表review_detail中创建一个新字段作为位置.
>在app / code / code / Mage / Adminhtml / Block / Review / Edit / Form.php中添加了以下代码

    $fieldset->addField('location', 'text', array(
            'name'  => 'location',
            'label' => Mage::helper('adminhtml')->__('Location'),
            'required' => false
        )
    ); 

就在上面:

    $fieldset->addField('nickname', 'text', array(
        'label'     => Mage::helper('review')->__('Nickname'),
        'required'  => true,
        'name'      => 'nickname'
    ));

>.在app / code / core / Mage / Review / Model / Resource / Review.php中添加了以下代码

$detail = array(
    'title'     => $object->getTitle(),
    'detail'    => $object->getDetail(),
    'nickname'  => $object->getNickname(),
    'location'  => $object->getLocation()   /* added */
);

>在下面的函数数组中添加了“location”.在文件中:app / code / core / Mage / Review / Model / Resource / Review / Collection.php

protected function _initSelect()
{
    parent::_initSelect();
    $this->getSelect()
        ->join(array('detail' => $this->_reviewDetailTable),
            'main_table.review_id = detail.review_id',
            array('detail_id', 'title', 'detail', 'nickname', 'customer_id','location'));
    return $this;
}

>在{$mytheme} /template/review/form.phtml中添加了以下内容:

<li>
      <label for="location_field" class="required"><em>*</em><?php echo $this->__('Location') ?></label>
      <div class="input-box">
           <input type="text" name="nickname" id="location_field" class="input-text required-entry" value="<?php echo $this->htmlEscape($data->getLocation()) ?>" />
      </div>
</li>   

我的问题是虽然我可以在管理面板中看到一个新字段,但每当我提交一个评论表单时,它都没有被提交/存储在数据库中.

我甚至重新索引并清除了缓存.

我应该做些什么来使其正常工作?

请帮忙…我在magento 1.8.

PS:我知道不应该更改核心文件.一旦我在这个问题上取得成功,我将把它覆盖到新模块.

解决方法:

我确实遵循了在排队中解释的确切步骤.并发现它正常工作.

我遇到的唯一问题是{$mytheme} /template/review/form.phtml

您已为位置字段定义name =“nickname”而不是name =“location”

更正此问题,如果您仍然面临同样的问题,请检查模块类是否被覆盖.

标签:php,magento,magento-1-8
来源: https://codeday.me/bug/20190703/1366888.html