0

I'm trying to hide the field "Last Name" from the admin page, but I'm not sure what I need to change since the HTML gets populated from a JS code. I'm trying to do the exact same thing mentioned at Remove field in Customer Account Information but on Magento 2. Is this possible?

0

The fields can be found at /vendor/magento/module-customer/view/base/ui_component/customer_form.xml. To hide Last Name, open the file and set "lastname" visibility to false:

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

<field name="lastname">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
        <item name="visible" xsi:type="boolean">false</item>      
        <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">
            <item name="required-entry" xsi:type="boolean">false</item>
        </item>
    </argument>
</field>

Afterwards, clean and flush the cache for the changes to take place.

  • How can you advice someone to change a code in vendor directory? How is this a good practice? – Bunyamin Inan Jul 17 at 17:22

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.