I want to add a Popup for product review form.

I was able to create pop up with js:

    function ($) {
        "use strict";
        //creating jquery widget
        $.widget('vendor.modalForm', {
            options: {
                modalForm: '#modal-form',
                modalButton: '.open-modal-form'
            _create: function () {
                this.options.modalOption = this._getModalOptions();
            _getModalOptions: function () {
                 * Modal options
                var options = {
                    type: 'popup',
                    responsive: true,
                    title: '',

                return options;
            _bind: function () {
                var modalOption = this.options.modalOption;
                var modalForm = this.options.modalForm;

                $(document).on('click', this.options.modalButton, function () {
                    //Initialize modal
                    //open modal

        return $.vendor.modalForm;

I need to make it work to were when people click link it shows the review form:

Here is my html for the .phtml file:

<div style="display:none;" id="modal-form">
    <?php include ($block->getTemplateFile('Magento_Review::form.phtml')) ?>
    // here should go the code for the form
<a class="action open-modal-form" href="#" title="Modal">
    <span>Review Product</span>
<script type="text/x-magento-init">
        ".open-modal-form": {
            "Vendor_Module/js/modal-form": {}

Any Suggestions to make this work?

I added the code: <?php include ($block->getTemplateFile('Magento_Review::form.phtml')) ?> but it doesn't bring the product form it shows as if I had to register or login to create the review. Is there a way to pass the product id variable? I have that on my .phtml

  • Did you get solution for this? – Jai Feb 9 '17 at 4:31
  • If you get a solution please post it – Jaisa Dec 8 '17 at 5:11

The problem here is that the Block class Form.php (Magento\Review\Block\Form) is not accessible as you have just included the PHTML file without its class.

You need to change below mentioned line of code:

<?php include ($block->getTemplateFile('Magento_Review::form.phtml')) ?>


<?php echo $this->getLayout()->createBlock("Magento\Review\Block\Form")->setTemplate("Magento_Review::form.phtml")->toHtml(); ?>

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.