0

I changed product review form but it shows some error after submitting form :

  <div class="form-add">
    <h2><?php echo $this->__('Write Your Own Review') ?></h2>
    <?php if ($this->getAllowWriteReviewFlag()): ?>
    <form action="<?php echo Mage::helper('em0113settings')->getActionReview()?>" method="post" id="review-form"><?php echo $this->getBlockHtml('formkey'); ?>
        <?php echo $this->getBlockHtml('formkey'); ?>
        <fieldset>
            <?php echo $this->getChildHtml('form_fields_before')?>
            <h3><?php echo $this->__("You're reviewing:"); ?> <span><?php echo $this->escapeHtml($this->getProductInfo()->getName()) ?></span></h3>
            <?php if( $this->getRatings() && $this->getRatings()->getSize()): ?>
                <h4><?php echo $this->__('How do you rate this product?') ?> <em class="required">*</em></h4>
                <span id="input-message-box"></span>
                <table class="data-table" id="product-review-table">
                    <col />
                    <col width="1" />
                    <col width="1" />
                    <col width="1" />
                    <col width="1" />
                    <col width="1" />
                    <thead>
                        <tr>
                            <th>&nbsp;</th>
                            <th><span class="nobr"><?php echo $this->__('1 star') ?></span></th>
                            <th><span class="nobr"><?php echo $this->__('2 stars') ?></span></th>
                            <th><span class="nobr"><?php echo $this->__('3 stars') ?></span></th>
                            <th><span class="nobr"><?php echo $this->__('4 stars') ?></span></th>
                            <th><span class="nobr"><?php echo $this->__('5 stars') ?></span></th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php foreach ($this->getRatings() as $_rating): ?>
                        <tr>
                            <th><?php echo $this->escapeHtml($_rating->getRatingCode()) ?></th>
                        <?php foreach ($_rating->getOptions() as $_option): ?>
                            <td class="value"><input type="radio" name="ratings[<?php echo $_rating->getId() ?>]" id="<?php echo $this->escapeHtml($_rating->getRatingCode()) ?>_<?php echo $_option->getValue() ?>" value="<?php echo $_option->getId() ?>" class="radio" /></td>
                        <?php endforeach; ?>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
                <input type="hidden" name="validate_rating" class="validate-rating" value="" />
                <script type="text/javascript">decorateTable('product-review-table')</script>
            <?php endif; ?>
            </fieldset>
            <div class="buttons-set">
                <button type="submit" title="<?php echo $this->__('Submit Review') ?>" class="button"><span><span><?php echo $this->__('Submit Review') ?></span></span></button>
            </div>
    </form>
    <script type="text/javascript">
    //<![CDATA[
    var reviewStars = new SrkaReviewStars('product-review-table');
        var dataForm = new VarienForm('review-form');
        Validation.addAllThese(
        [
               ['validate-rating', '<?php echo $this->__('Please select one of each of the ratings above') ?>', function(v) {
                    var trs = $('product-review-table').select('tr');
                    var inputs;
                    var error = 1;

                    for( var j=0; j < trs.length; j++ ) {
                        var tr = trs[j];
                        if( j > 0 ) {
                            inputs = tr.select('input');

                            for( i in inputs ) {
                                if( inputs[i].checked == true ) {
                                    error = 0;
                                }
                            }

                            if( error == 1 ) {
                                return false;
                            } else {
                                error = 1;
                            }
                        }
                    }
                    return true;
                }]
        ]
        );
    //]]>
    </script>
    <?php else: ?>
    <p class="review-nologged" id="review-form">
        <?php echo $this->__('Only registered users can write reviews. Please, <a href="%s">log in</a> or <a href="%s">register</a>', $this->getLoginLink(), Mage::helper('customer')->getRegisterUrl()) ?>
    </p>
    <?php endif ?>
</div>

replace with:

<div class="form-add">
<h2><?php echo $this->__('Write Your Own Review') ?></h2>
<?php if ($this->getAllowWriteReviewFlag()): ?>
<form action="<?php echo Mage::helper('em0113settings')->getActionReview()?>" method="post" id="review-form"><?php echo $this->getBlockHtml('formkey'); ?>
    <fieldset class="rating">
        <?php echo $this->getChildHtml('form_fields_before')?>
        <h3><?php echo $this->__("You're reviewing:"); ?> <span><?php echo $this->escapeHtml($this->getProductInfo()->getName()) ?></span></h3>
        <?php if( $this->getRatings() && $this->getRatings()->getSize()): ?>
        <h4><?php echo $this->__('How do you rate this product?') ?> <em class="">*</em></h4>
        <span id="input-message-box"></span>
        <table class="data-table" id="product-review-table">
            <tbody>
                <input type="radio" id="star5" name="rating" value="5" /><label class = "full" for="star5" title="Awesome - 5 stars"></label>
                <input type="radio" id="star4half" name="rating" value="4 and a half" /><label class="half" for="star4half" title="Pretty good - 4.5 stars"></label>
                <input type="radio" id="star4" name="rating" value="4" /><label class = "full" for="star4" title="Pretty good - 4 stars"></label>
                <input type="radio" id="star3half" name="rating" value="3 and a half" /><label class="half" for="star3half" title="Meh - 3.5 stars"></label>
                <input type="radio" id="star3" name="rating" value="3" /><label class = "full" for="star3" title="Meh - 3 stars"></label>
                <input type="radio" id="star2half" name="rating" value="2 and a half" /><label class="half" for="star2half" title="Kinda bad - 2.5 stars"></label>
                <input type="radio" id="star2" name="rating" value="2" /><label class = "full" for="star2" title="Kinda bad - 2 stars"></label>
                <input type="radio" id="star1half" name="rating" value="1 and a half" /><label class="half" for="star1half" title="Meh - 1.5 stars"></label>
                <input type="radio" id="star1" name="rating" value="1" /><label class = "full" for="star1" title="Sucks big time - 1 star"></label>
                <input type="radio" id="starhalf" name="rating" value="half" /><label class="half" for="starhalf" title="Sucks big time - 0.5 stars"></label>
                  </tbody>
        </table>
            <input type="hidden" name="validate_rating" class="validate-rating" value="" />
            <script type="text/javascript">decorateTable('product-review-table')</script>
        <?php endif; ?>
        </fieldset>
        <div class="buttons-set">
            <button type="submit" title="<?php echo $this->__('Submit Review') ?>" class="button"><span><span><?php echo $this->__('Submit Review') ?></span></span></button>
        </div>
</form>
<script type="text/javascript">
//<![CDATA[
    var dataForm = new VarienForm('review-form');
    Validation.addAllThese(
    [
           ['validate-rating', '<?php echo $this->__('Please select one of each of the ratings above') ?>', function(v) {
                var trs = $('product-review-table').select('tr');
                var inputs;
                var error = 1;

                for( var j=0; j < trs.length; j++ ) {
                    var tr = trs[j];
                    if( j > 0 ) {
                        inputs = tr.select('input');

                        for( i in inputs ) {
                            if( inputs[i].checked == true ) {
                                error = 0;
                            }
                        }

                        if( error == 1 ) {
                            return false;
                        } else {
                            error = 1;
                        }
                    }
                }
                return true;
            }]
    ]
    );
//]]>
</script>
<?php else: ?>
<p class="review-nologged" id="review-form">
    <?php echo $this->__('Only registered users can write reviews. Please, <a href="%s">log in</a> or <a href="%s">register</a>', $this->getLoginLink(), Mage::helper('customer')->getRegisterUrl()) ?>
</p>
<?php endif ?>

Review summary can't be empty; Nickname can't be empty; Review can't be empty;

i already remove this fields from review form and comment this line of codes in review.php:

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');
    }

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

Then it was not showing error but not showing any successful message.why?

i already seen some question here

but i didn't get answer which solved my problem.

  • show us the changes that you have done. – Rajeev K Tomy Jul 6 '15 at 10:58
  • also specify whether this happens in admin side or in frontend side – Rajeev K Tomy Jul 6 '15 at 11:04
  • @Rajeev K Tomy I edited my question you can check code there ....it happens in front side.. – Urvashi Jul 6 '15 at 11:20
  • it is shoing error "Unable to post the review." – Urvashi Jul 6 '15 at 11:46
  • Did you copy the files (review.php and form.phtml) from the core directory to your local one? – Daniel Barenboim Mar 8 '17 at 21:19

Your Answer

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

Browse other questions tagged or ask your own question.