0

/Blockname.php/

<?php
namespace Eaglerocket\Customquote\Block;

use Magento\Framework\View\Element\Template;

class Blockname extends Template
{

    protected $_registry;

    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Framework\Registry $registry,
    )
    {
        $this->_registry = $registry;
        parent::__construct($context);
    }

    public function getCurrentProduct()
    {
        return $this->_registry->registry('current_product');
    }

}

/post_requirements.phtml/

 <?php 
    if ($currentProduct = $block->getCurrentProduct()) {
        echo $currentProduct->getName() . '<br />';
        echo $currentProduct->getSku() . '<br />';
        echo $currentProduct->getFinalPrice() . '<br />';
        echo $currentProduct->getProductUrl() . '<br />';
        print_r ($currentProduct->getCategoryIds()) . '<br />';
    }
     ?>
    
    <button type="button" class="btn btn-primary btn-lg" id="popupButton" data-toggle="modal"
      data-target="#myModal"><?php echo __('Post Requirement')?></button>
      <!-- Modal -->
      <div class="modal fade" id="myModal" role="dialog" style="display:none;">
        <div class="modal-dialog">
          <!-- Modal content-->
          <div class="modal-content">
            <div class="modal-header">
              <h4 class="modal-title"><?php echo __('Get Quote')?></h4>
            </div>
            <div class="modal-body">
        <form action="<?= $block->escapeUrl($block->getBaseUrl().'customquote/index/submit')?>" method="post">
    
    
             
          <div class="form-group">
            <label for="name"><?php echo __('Name');?>:</label>
            <input type="text" class="form-control" id="name" placeholder="<?php echo __('Enter name')?>" name="product_name" value="<?= $block->escapeUrl($block->getBaseUrl().'customquote/index/submit')?>">
          </div>
          <div class="form-group">
            <label for="requirement"><?php echo __('Requirement') ?> :</label>
            <input type="text" class="form-control" id="name" placeholder="<?php echo __('Enter name')?>" name="question" 
            value="<?= $block->escapeUrl($block->getBaseUrl().'customquote/index/submit')?>">
          
         <!--  <textarea class="form-control" rows="5" id="requirement" name="answer">
            </textarea> -->
          </div>
          <div class="form-group">
            <label for="requirement"><?php echo __('Requirement') ?> :</label>
                
    <input type="text" class="form-control" id="name"  name="answer" 
            value="<?php echo $currentProduct->getName();?>">  
    </div>
    
          <button type="submit" class="btn btn-default"><?php echo __('Submit')?></button>
        </form>
            </div>
          </div>
        </div>
      </div>
    <script>
      require(['jquery', 'Eaglerocket_Customquote/js/mymodal-component'],
          function ($) {
              return;
          }
      );
      </script>
2
  • Are you still facing issue?
    – ZealousWeb
    Jun 22 at 9:51
  • It solved.Array ( [0] => Array ( [post_id] => 1 [question] => ytrtyetrsyt [priority] => 2 [tags] => jhbjb [status] => 1 [created_at] => 2021-06-16 17:57:35 [updated_at] => 2021-06-17 07:29:24 ) ) In this form I am getting the table data and I only need question field. Since everything is working here in object form so how to capture the question field?
    – kks
    Jun 23 at 11:11

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.