1

I want to override vendor/module/view/adminhtml/ui_component/example.xml to my own custom module.

steps that I did :

Creating etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="myModule" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Cron" />
        </sequence>
    </module>
</config>

creating registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'myModule',
    __DIR__
); 

creating view/adminhtml/ui_component/example.xml

// my custom code

Creating view/adminhtml/layout/myLayout.xml

<?xml version="1.0" encoding="UTF-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="styles"/>
    <body>
        <referenceContainer name="content">
            <uiComponent name="example"/>
        </referenceContainer>
    </body>
</page>

but in the end, my custom module not overriding the other module, am I missing something when overriding? thank you in advance

4
  • do you want to add new code Or want to update exiting code from ui_component ?
    – Pawan
    Sep 28 '21 at 15:55
  • @Pawan i want to update some existing code. let say i want to change 1 tag inside parent module
    – Wavesolid
    Sep 29 '21 at 4:56
  • You can just create file with same name and path in your custom module...in your custom module use same field name and do your changes.. it will automatically took form your custom module instead of existing..
    – Pawan
    Sep 29 '21 at 15:48
  • if it is magento's ui_comonent..it will automatic work or you may need to add <sequence><module name="Magebto_ModuleName"/></sequence> in your module.xml
    – Pawan
    Sep 29 '21 at 15:51
1

Hi there I know it's too late to answer this one, but bear with me I saw this now only and experimented the same, from your question, I'm able to understand that in UI form which is coming from a third party module, you want to over-ride that and add an extra new field, please find the below code for a third party module and new module which add that new extra field.

  1. In this third-party module they have a field, so I have over-ridden it by using sequence element, and using the same directory structure of that UI component file, please refer to the below screenshot.
  2. enter image description here

3. Now all you have to do is, register a module and use sequence with their module. 4. And follow the same directory structure for their file with yours. 5. After that, please create the file name as same as their file name, so that it will be suitable to override the file. 6. For sample purposes, please refer to the below XML code of the UI component where I have added an extra field in the third part custom module UI form.

<dataSource name="vendor_module_form_data_source" component="Magento_Ui/js/form/provider">
    <settings>
        <submitUrl path="vendor/module/save"/>
    </settings>
    <dataProvider class="Vendor\Module\Model\Data\DataProvider" name="vendor_module_form_data_source">
        <settings>
            <requestFieldName>id</requestFieldName>
            <primaryFieldName>id</primaryFieldName>
        </settings>
    </dataProvider>
</dataSource>

<fieldset name="image_information">
    <field name="identifier_custom" sortOrder="2" formElement="input">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="source" xsi:type="string">newform</item>
            </item>
        </argument>
        <settings>
            <validation>
                <rule name="required-entry" xsi:type="boolean">true</rule>
            </validation>
            <dataType>text</dataType>
            <label translate="true">Identifier Custom</label>
            <dataScope>identifier</dataScope>
        </settings>
    </field>
</fieldset>

</form>

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.