Search code examples
phpmagentomagento-1.8

Review form is not being submitted


In my project, I added a new field location in "product reviews" of admin panel going through the following steps as explained in many blogs.

  • Created a new field in database table review_detail as location.
  • Added the following code in app/code/code/Mage/Adminhtml/Block/Review/Edit/Form.php

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

Just above:

    $fieldset->addField('nickname', 'text', array(
        'label'     => Mage::helper('review')->__('Nickname'),
        'required'  => true,
        'name'      => 'nickname'
    ));
  • .Added the following code in app/code/core/Mage/Review/Model/Resource/Review.php

    $detail = array(
        'title'     => $object->getTitle(),
        'detail'    => $object->getDetail(),
        'nickname'  => $object->getNickname(),
        'location'  => $object->getLocation()   /* added */
    );
    
  • Added "location" in below function array. In the file: 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;
    }
    
  • Added the following in {$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>   
    

My problem is that though I can see a new field in admin panel, whenever I submit a review form it is not being submitted/stored in database.

I even re-indexed and cleared the cache.

What should I change more to make it work properly?

Please help... I am on magento 1.8.

PS: I know core files should not be changed. I will override this to new module once I have success in this issue.


Solution

  • I did follow exact steps explained in quetion. And find it working properly.

    Only issue I faced was that in {$mytheme}/template/review/form.phtml

    You have defined name="nickname" for location field instead of name="location"

    Correct this and if you still face same issue than then check if Module Classes as being overridden.