4

Is there any option to override magento-ui vendor/magento/module-ui/view/base/web/templates templates from a theme?

Other module's templates overriding works fine:

var config = {
 map: {
 '*': {
 'Magento_Checkout/template/estimation.html': 'template/module-checkout/estimation.html',
 'Magento_Checkout/template/progress-bar.html': 'template/module-checkout/progress-bar.html'
 }
 }
};

But I see that module-ui templates' path is declared this way:

var config = {
 paths: {
 'ui/template': 'Magento_Ui/templates'
 }
}

And I can't override this file:

vendor/magento/module-ui/view/base/web/templates/form/element/textarea.html

Prince Patel
23.1k10 gold badges102 silver badges124 bronze badges
asked Dec 8, 2016 at 17:28
4
  • Have you did it? Commented Mar 27, 2019 at 6:41
  • But not work for me. What you write in 'requirejs-config.js'? Commented Mar 27, 2019 at 10:52
  • Where you want to override? In a module or in a theme? Commented Mar 27, 2019 at 13:14
  • In a module.... Commented Mar 27, 2019 at 13:22

2 Answers 2

7

Did you try to create in your theme a Magento_Ui/web/templates/form/element/textarea.html file ? This should override the base one , also don't forget to remove the theme files from pub/static/, this worked for me

Or in your custom module , create a [Namespace]/[Module]/view/frontend/requirejs-config.js file in your module with the following code

var config = {
 map: {
 '*': {
 'Magento_Checkout/template/estimation.html': '[Namespace]_[Module]/template/module-checkout/estimation.html',
 'Magento_Checkout/template/progress-bar.html': '[Namespace]_[Module]/template/module-checkout/progress-bar.html'
 }
 }
};
answered Dec 8, 2016 at 18:37
6
  • Creating the exact path works, but the requirejs-config.js does not with Magento_Ui... I tried everything possible... If someone knows how to do it... Commented Aug 3, 2017 at 14:02
  • @PolRavalitera What exactly do you want to do? Commented Aug 4, 2017 at 10:18
  • @VladPetru I want to rewrite form/field.html from the requirejs-config.js , in order to put my new field.html in a module. I cleaned cache, everything, that just do not work on 2.1.7. The exact path in theme worsk (Magento_Ui etc). Commented Aug 4, 2017 at 12:57
  • @PolRavalitera I just tried to override that exact file, it is working but be carefull, the requirejs-config file doesn't always update after one refresh, if the cache is done for some files it leaves them like they are. You should clear magento2 cache and browser cache, if its not working manualy delete the file from pub/static/frontend/[Namespace]/[Theme]/[lang_code]/Magento_Ui/templates/form/ Commented Aug 8, 2017 at 8:56
  • @VlaPatru I just add a lot of problem on that, i had to delete static/frontend/_requirejs . I don't know why, but the "secure" version of it is not updated... So i thought maybe that was just that last time with this problem. I will retry. Thx you for looking into it !!! Commented Aug 9, 2017 at 7:53
2

Create requirejs-config.js file from [Namespace]/[Module]/view/base.

So path will be [Namespace]/[Module]/view/base/requirejs-config.js

 var config = {
 map: {
 '*': {
 'Magento_Checkout/template/estimation.html': '[Namespace]_[Module]/template/module-checkout/estimation.html',
 'Magento_Checkout/template/progress-bar.html': '[Namespace]_[Module]/template/module-checkout/progress-bar.html'
 }
 }
 };

and run the commands

php bin/magento cache:flush php bin/magento cache:clean

then you can check [root]/[pub]/[static]/[_requirejs]/[frontend]/[Namespace]/[theme]/[en_US]/requirejs-config.js your code will update here.

So it will work. feel free to ask if you have any queries?

answered Dec 9, 2016 at 4:50
1
  • How can I override file-uploader.js from module-ui under web/js/form/element ? I did try as you suggested but not working. Commented Feb 4, 2019 at 6:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.