0

I have created custom module for magento review module, Now All the functionalities works fine. But default magento validation is failed for Review form. Now, How do i trigger the dafault validation to my custom module

1

Just Add this data-hasrequired=" Required Fields" data-mage-init='{"validation":{}}' line to your form tag as show in below example and need to set validation class in input element like data-validate='{}'

<form id="test" name="test" method="post"  action="<?php echo $block->getUrl('test/index/test'); ?>" data-hasrequired="* Required Fields"  data-mage-init='{"validation":{}}'>
    <div class="input-box">
         <input name="name" id="name" title="<?php echo __('First name / last name'); ?>" value="" class="input-text required-entry" type="text" data-validate='{"required":true}'>
         </div>
    </form>

For fore info please follow this links http://inchoo.net/magento-2/validate-custom-form-in-magento-2/

  • Thanks for your response. Validation is worked for other fields except star rating – Jaisa Jan 19 '18 at 13:03
  • I need to validate including star rating in Review module – Jaisa Jan 19 '18 at 13:03
  • For that you have to add custom validation and validate – Navin Bhudiya Jan 19 '18 at 13:14
  • I have overrided the form.phtml from Magento\Review\view\frontend\templates\form.phtml to my custom module. Then, Why do I need to do custom validation for star rating. Can you help me if i am wrong – Jaisa Jan 19 '18 at 13:34
  • Validation for star rating is come from in Magento Review module."Magento_Review/js/validate-review" – Jaisa Jan 19 '18 at 13:37

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.