【问题标题】:Review form is not being submitted审核表未提交
【发布时间】:2013-12-22 12:22:04
【问题描述】:

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

  • 在数据库表 review_detail 中创建了一个新字段为 location
  • 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:我知道核心文件不应该更改。一旦我在这个问题上取得成功,我将把它覆盖到新模块。

【问题讨论】:

    标签: php magento magento-1.8


    【解决方案1】:

    我确实遵循了问题中解释的确切步骤。并发现它工作正常。

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

    您为位置字段定义了name="nickname",而不是name="location"

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

    【讨论】:

    • 我从没想过这个.. 将name 设置为“位置”解决了这个问题。非常感谢:)
    【解决方案2】:

    查看在浏览器中创建的 html 代码。检查:

    • 您的字段是否包含在 -tags 中?
    • 动作类型和目标设置是否正确?
    • 使用您选择的浏览器控制台(例如 chrome F12)确保正确设置字段并真正发送表单。

    【讨论】:

      【解决方案3】:

      试试这个,先备份数据库。从 core_resource 表中删除表条目并加载站点。简而言之,尝试使用您的列“位置”重新创建数据库表。我不知道,当我们以各种形式添加新字段时,setter 有什么问题,它们无法正常工作。

      我希望这会奏效。

      【讨论】:

        猜你喜欢
        • 2017-08-24
        • 2014-01-29
        • 1970-01-01
        • 1970-01-01
        • 2022-01-13
        • 1970-01-01
        • 1970-01-01
        • 2013-12-08
        • 2016-11-08
        相关资源
        最近更新 更多