cancel
Showing results for 
Search instead for 
Did you mean: 

Overwrite input.html in Magento UI in my module

SOLVED

Overwrite input.html in Magento UI in my module

I'm trying to overwrite input.html in module-ui > view > frontend > web > templates > form> element in my module.

 

Somehow it isn't working whatever I try.

 

I currently got this in my requirejs-config.js.

 

var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/view/shipping': {
                'BB_Checkout/js/mixin/shipping-mixin': true
            }
        }
    },
    'map': {
        '*': {
            'Wezz_Postcode/js/view/postcode': 'BB_Checkout/js/view/postcode-overwrite',
            'Magento_Ui/templates/form/element/input': 'BB_Checkout/templates/form/element/input-overwrite'
        }
    }
};

I also already tried clearing my M2 cache en browser cache.

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Overwrite input.html in Magento UI in my module

Ah apparently Magento_Ui/templates is mapped to ui/template in Magento\vendor\magento\module-ui\view\base\requirejs-config.js

 

So after adding ui/template it works.

View solution in original post

3 REPLIES 3

Re: Overwrite input.html in Magento UI in my module

Ah apparently Magento_Ui/templates is mapped to ui/template in Magento\vendor\magento\module-ui\view\base\requirejs-config.js

 

So after adding ui/template it works.

Re: Overwrite input.html in Magento UI in my module

Sorry, where have you added ui/template?

 

I am having a hard time trying to override the dynamic rows template, but it only seems to work with the structure like this:

 

<dynamicRows name="dynamic_rows_fields">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="component" xsi:type="string">Namespace_Module/js/dynamic-rows/dynamic-rows</item>
                   <item name="template" xsi:type="string">ui/dynamic-rows/templates/default</item>
(...)

 

If I change the template ui/dynamic-rows/templates/default to my Module's template it doesn't work...

 

Thanks in advance!

Re: Overwrite input.html in Magento UI in my module

I have just figured it out.

 

Didn't need to make any changes to my requirejs file, I was just creating the template file in the wrong place.

 

So to override the dynamic-rows/templates/default.html i have created a new file:

 

app/code/Namespace/MyModule/view/adminhtml/web/template/dynamic-rows/templates/default.html

 

And inside my ui_form.xml:

 

<dynamicRows name="dynamic_rows_fields">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
<!-- extending the dynamic-rows.js --> <item name="component" xsi:type="string">Namespace_MyModule/js/dynamic-rows/dynamic-rows</item> <!-- extending the template -->
<item name="template" xsi:type="string">Namespace_MyModule/dynamic-rows/templates/default</item> </item> </argument>