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

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?
    – Arthanis
    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'
        }
    }
};
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?
    – Vlad Patru
    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/
    – Vlad Patru
    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?

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.
    – anonymous
    Commented Feb 4, 2019 at 6:22

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.