0

How Can I Add Button For Submit Reviews On Click On This Button Submit Reviews Pop up form Open And User Can Easily Submit The Reviews .

enter image description here

1 Answer 1

0

Add this code to your phtml file

<div>
    <button type="button" id="click-me">Click Me!</button>
</div>

<div id="popup-modal" style="display:none;">
    <?php
        echo $this->getLayout()->createBlock(\Magento\Review\Block\Form::class)->setTemplate('Magento_Review::form.phtml')->toHtml();
    ?>
</div>

<script>
    require(
        [
            'jquery',
            'Magento_Ui/js/modal/modal'
        ],
        function(
            $,
            modal
        ) {
            var options = {
                type: 'popup',
                responsive: true,
                innerScroll: true,
                title: 'Your Title title',
                buttons: [{
                    text: $.mage.__('Close'),
                    class: '',
                    click: function () {
                        this.closeModal();
                    }
                }]
            };

            var popup = modal(options, $('#popup-modal'));
            $("#click-me").on('click',function(){ 
                $("#popup-modal").modal("openModal");
            });

        }
    );
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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