1

I want to change :

magento/module-ui/view/base/web/js/form/element/date.js file

and set my custom date file , for this purpose I've added this line to my requirejs-config in my module :

'map': {
    '*': {
        'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/date_form'
    }
},

but when I refresh page I get this error in console :

Uncaught TypeError: elem.initContainer is not a function at UiClass.initElement (collection.js:57)

and magento can't load date input element .

I think the problem is this part at date.js :

elementTmpl: 'ui/form/element/date',

it seems magento can't find this path for load it's html template .

I changed template path to this :

elementTmpl: 'Magento_Ui/form/element/date',

but noting changed .

how can I change this path base on my module ?

note : I don't want change date.html template file and I want to use magento default template file .

  • better put it on the same path like this 'map': { '*': { 'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/form/element/date' } }, – fmsthird Apr 2 at 21:25
  • @magefms thank you for reply , I did'nt get what you mean , elementTmpl path is in my custom date.js file magento can't find this path for load html template file. I think because this file is in my module , magento can't resolve this path . – Behzad kahvand Apr 2 at 21:36
  • yeah, you are right. what I mean is, instead of putting your custom date.js somewhere in your custom module put it in the same level with the core date.js in your custom module. check my first comment – fmsthird Apr 2 at 21:48
  • @magefms , you were right, my problem was solved . thanks alot . – Behzad kahvand Apr 2 at 22:04
1

It is better to put your custom date.js on the same path level of core date.js like this

'map': { 
    '*': { 

        'Magento_Ui/js/form/element/date' : 'MyNamespace_MyModule/js/form/element/date' 
      }
 }, 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.