0

I want to add a custom field to the review form in Magento. I have tried this but the data is not saved, it shows the field.

app\code\core\Mage\Adminhtml\Block\Review\Edit\Form.php

$fieldset->addField('email', 'text', array( // New field 1
'label' => Mage::helper('review')->__('Email'),
'required' => true,
'name' => 'email'
));

After

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

app\design\frontend\theme\theme\template\review\form.phtml

        <li class="formlistreview">
            <label for="email_field" class="required"><em>*</em><?php echo $this->__('E-mail') ?></label>
            <div class="input-box">
                <input type="text" name="email" id="email_field" class="input-text required-entry" value="<?php echo $this->htmlEscape($data->getEmail()) ?>" />
            </div>
        </li>

app\code\core\Mage\Review\Model\Resource\Review.php

protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$detail = array(
'title' => $object->getTitle(),
'detail' => $object->getDetail(),
'nickname' => $object->getNickname(),
'email' => $object->getEmail(), // New field 1
);

What am I missing?

2 Answers 2

3

use $this instead of $object

protected function _afterSave(Mage_Core_Model_Abstract $object)
{
$detail = array(
'title' => $this->getTitle(),
'detail' => $this->getDetail(),
'nickname' => $this->getNickname(),
'email' => $this->getEmail(), // New field 1
);
2
  • @TejabhagavanKollepara dear check the error log what error their check for exception and etc what i can do from only url? Jan 12, 2017 at 12:46
  • 1
    The default code with $object worked for me, even for my custom field. I did however have to add the custom field as column to review_detail in my database. Nov 25, 2020 at 14:07
2

You need to do is add a column email in review_detail table. Then this issue would be resolved.

It's too old post, but it might help someone. So, i just figured out the solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.