3

When I review a product, there is a required field of Review on the last. I want to change this field from required to not required.

I changed this field for backend by editing app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php.

$fieldset->addField('detail', 'textarea', array(
    'label'     => Mage::helper('review')->__('Review'),
    'required'  => false,
    'name'      => 'detail',
    'style'     => 'height:24em;',
));

Now I want to change it for frontend. How to do it?

4
$fieldset->addField('detail', 'textarea', array(
            'label'     => Mage::helper('review')->__('Review'),

            'name'      => 'detail',
            'style'     => 'height:24em;',
        ));

i just tried it and it working.

app/code/core/Mage/Adminhtml/Block/Review/Edit/Form.php
  • tried. Same result. Not working. – umair ayub Jun 18 '15 at 7:30
  • i remove 'required' => true, on 127 line. that work – Qaisar Satti Jun 18 '15 at 7:39
  • you are adding the review or editing the review? – Qaisar Satti Jun 18 '15 at 7:45
  • i am adding a review from frontend. – umair ayub Jun 18 '15 at 7:45
  • got app/design/frontend/(yourtheme or base )/default/template/review/form.phtml and remove class="required-entry" from line 85 or textarea field – Qaisar Satti Jun 18 '15 at 7:50
5

go to the app/design/frontend/base/default/template/review/form.phtml and replace this code

<label for="review_field" class="required"><em>*</em><?php echo $this->__('Review') ?></label>
<div class="input-box">
     <textarea name="detail" id="review_field" cols="5" rows="3" class="required-entry"><?php echo $this->escapeHtml($data->getDetail()) ?></textarea>
</div>

with the below code

<label for="review_field"><?php echo $this->__('Review') ?></label>
<div class="input-box">
    <textarea name="detail" id="review_field" cols="5" rows="3"><?php echo $this->escapeHtml($data->getDetail()) ?></textarea>
</div>
  • in that case, when i submit review, it says "review can not be empty". – umair ayub Jun 18 '15 at 7:45
1

In Append to Piyush post. Remove validation from server side as below.

create a custom module and rewrite "Mage_Review_Model_Review" class as below.

In your custom module config.xml file. add below code under "models" node.

<global>
...........
....... 
...
<models>
  <modulename>
    <class>Your_Modulename_Model</class>
    <resourceModel>modulenam_mysql4</resourceModel>
  </modulename>
        <review>
            <rewrite>
                <review>Your_Modulename_Model_Review_Review</review>
            </rewrite>
        </review>
</models>
...........
.....
</global>    

Now in Your "Your_Modulename_Model_Review_Review" model class add below code.

<?php
class Your_Modulename_Model_Review_Review extends Mage_Review_Model_Review
{


 public function validate()
{
    $errors = array();

    if (!Zend_Validate::is($this->getTitle(), 'NotEmpty')) {
        $errors[] = Mage::helper('review')->__('Review summary can\'t be empty');
    }

    if (!Zend_Validate::is($this->getNickname(), 'NotEmpty')) {
        $errors[] = Mage::helper('review')->__('Nickname can\'t be empty');
    }
 // comment below code to remove details field valiation.
 //   if (!Zend_Validate::is($this->getDetail(), 'NotEmpty')) {
  //      $errors[] = Mage::helper('review')->__('Review can\'t be empty');
  //  }
//
   if (empty($errors)) {
        return true;
    }
    return $errors;
   }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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