New answers tagged

0 votes

Magento 2.4.x: How to pass custom variable from controller to phtml file?

I had to work on same requirement and i achieved as below. Controller Class namespace Vendor\Module\Controller\Index; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\Context;...
user avatar
0 votes

Magento 2.4.x: How to pass custom variable from controller to phtml file?

You can do it with static variable like below. Controller class. <?php namespace Vendorname\Modulename\Controller\Index; use Magento\Framework\App\Action\Action; use Magento\Framework\App\Action\...
user avatar
  • 1,049
0 votes

Magento 2.4.x: How to pass custom variable from controller to phtml file?

it's also possible by ajax call. By using that controller variable could be call in phtml file. Phtml file <div id ="Div_id"></div> <script type="text/javascript"&...
user avatar
0 votes

Magento 2.4.x: How to pass custom variable from controller to phtml file?

When you create your block with $block = $this->_view->getLayout()->createBlock('module\Block\Adminhtml\CustomBlock');, you can pass data to it using the 3rd argument to the createBlock ...
user avatar
2 votes

Magento 2.4.x: How to pass custom variable from controller to phtml file?

Why would you want to use a registry ? Is there a reason beyond this ? You need to pass variables threw controller and block depending on how the templates is defined. For example : Template ...
user avatar
  • 737
0 votes

Magento 2 Page builder product attribute cannot render html

Try this - may it will help you. helper('Magento\Catalog\Helper\Output')->productAttribute($_product, $_product->get@attribute_code(), '@attribute_code'); ?> #magento2 #pagebuildermagento2 #php #phtml
user avatar
0 votes

Add a static image on PHTML page and CMS Blocks : Magento2

Use Module image : $block->getViewFileUrl('Vendor_Module::images/test.jpg'); Use Theme image : $block->getViewFileUrl('images/test.jpg');
user avatar
0 votes

Magento 2: Get image url in phtml file

Use Module image : $block->getViewFileUrl('Vendor_Module::images/test.jpg'); Use Theme image : $block->getViewFileUrl('images/test.jpg');
user avatar
0 votes

Field number validation

@Ocastro I have something like that. As I said. The other rules work correctly. Only on this field neither number nor validate-number validation works for me. <script type="text/x-magento-init&...
user avatar
  • 27
1 vote
Accepted

Field number validation

Would you be able to post the entire form code? I suspect that you are missing the initialization of the mage/validation library. Please see here In order for the validation rules to work. You must ...
user avatar
  • 498
0 votes

How to add view model to existing phtml and block

All the XML files will be merged in the end, so we can directly use the block name in the referenceBlock tag and change the template and add the view model for additional functionalities. Find the ...
user avatar
  • 425
0 votes

How to add view model to existing phtml and block

Even though its late to answer your question, it may help someone. You can add viewModel like below arguments syntax. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
user avatar
  • 53
0 votes

Magento 2.4.3 create custom pdf

First add dompdf using composer composer require dompdf/dompdf Now add a helper class in your module, like app/code/Vendor/Module/Helper/HtmltoPdf.php Use following code for your helper file: <?...
user avatar
  • 8,780

Top 50 recent answers are included