0

I'm trying to override the following file and I need the changes to show in adminhtml.

vendor/magento/module-customer/view/base/ui_component/customer_form.xml

I have copied the file to the location below and made the changes.

app/code/[vendor]/[module]/view/base/ui_component/customer_form.xml

However the changes aren't showing up.

Tried a few different places such as overrides/adminhtml etc. I've also tried just including the fields/arguments I want to change and searching for the proper way to overwrite this file but haven't been able to get it working yet.

Edit: adding code of xml file after request

My first attempt was to copy the entire file and only change the value I needed (switching lastname validation to false). So that should be same as core except those two values. My second attempt to override the file only including the fields I changed is below.

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="customer">
        <field name="lastname">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="formElement" xsi:type="string">input</item>
                    <item name="source" xsi:type="string">customer</item>
                    <item name="validation" xsi:type="array">
                        <!-- this should work but doesn't appear to, needed to do a core hack instead -->
                        <item name="required-entry" xsi:type="boolean">false</item>
                    </item>
                </item>
            </argument>
        </field>
    </fieldset>
    <fieldset name="address">
        <field name="lastname">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="formElement" xsi:type="string">input</item>
                    <item name="source" xsi:type="string">address</item>
                    <item name="validation" xsi:type="array">
                        <!-- this should work but doesn't appear to, needed to do a core hack instead -->
                        <item name="required-entry" xsi:type="boolean">false</item>
                    </item>
                    <item name="imports" xsi:type="array">
                        <item name="default" xsi:type="string">${ $.provider }:data.customer.lastname</item>
                    </item>
                </item>
            </argument>
        </field>
    </fieldset>
</form>
  • The path used is right, there maybe something wrong with the content of the file. Please post the code for customer_form.xml. – Vivek Kumar Mar 19 '18 at 6:15
  • Check overrided path it must be app/code/Vendor/Module/view/base/ui_component/customer_form.xml – Prince Patel Mar 19 '18 at 6:15
0

Try placing it in app/code/Vendor/Module/view/adminhtml/ui_component/customer_form.xml with the following content

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="address">
    <field name="lastname">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="validation" xsi:type="array">
                    <!-- this should work but doesn't appear to, needed to do a core hack instead -->
                    <item name="required-entry" xsi:type="boolean">false</item>
                </item>
            </item>
        </argument>
    </field>
</fieldset>
</form>

XML files are not overriden as they used to be in M1, instead you need to created file in your module and place what you want to add, then all should files be merged.

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.