Reputation: 41842
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.
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.
Upvotes: 4
Views: 1411
Reputation: 502
Try this, take db backup first. Delete entry of table from core_resource table and load the site.. In short try to recreate the db table with your column 'location'. I don't know ,what is wrong with setters when we add new field in varien forms they didn't work properly.
I hope this will work.
Upvotes: 0
Reputation: 1514
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.
Upvotes: 2
Reputation: 1107
Have a look at the html code created in the browser. Check for:
Upvotes: 0