2

I have created customer Attribute programmatically and need that attribute to outside of "Account information" tab... means in custom tab.

enter image description here

I have tried with customer group.... ui component file as below

<fieldset name="custom_fields">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="label" xsi:type="string" translate="true">Custom Fields</item>
            <item name="collapsible" xsi:type="boolean">true</item>
            <item name="opened" xsi:type="boolean">true</item>
        </item>
    </argument>
    <field name="customer_blood_group">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string" translate="true">Blood Group</item>
                <item name="visible" xsi:type="boolean">true</item>
                <item name="dataType" xsi:type="string">number</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">customer_blood_group</item>
            </item>
        </argument>
    </field>
</fieldset>

but it's not working... any other way to sort out this issue ?

thanks in advance

5
  • Can you try this rakeshjesadiya.com/… Commented Dec 30, 2019 at 7:27
  • i have created custom tab... need to add customer attribute inside that Commented Dec 30, 2019 at 7:29
  • Hi @rakeshprajapati please check my updated answere Commented Dec 30, 2019 at 9:11
  • Hello @rakeshjesadiya your code is good but I need to customer attribute display in custom tab and there field drop-down can you help me this matter Commented Jun 16, 2021 at 5:59
  • @rakeshprajapati Any solution found?
    – milan
    Commented Nov 26 at 13:56

1 Answer 1

0

Please try this:app/code/Vendor/Module/view/base/ui_component/customer_form.xml

     <?xml version="1.0" encoding="UTF-8"?>
     <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
        <settings>
            <collapsible>true</collapsible>
            <label translate="true">CMS Page Hierarchy</label>
        </settings>
        <fieldset name="custom_fields">
                <field name="customer_blood_group" formElement="input">
                    <settings>
                        <label translate="true">Custome</label>
                        <dataType>number</dataType>
                        <visible>true</visible>
                        <dataScope>customer_blood_group</dataScope>
                    </settings>
                </field>
            </fieldset>
        </form>

OR

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
   <fieldset name="test">
       <argument name="data" xsi:type="array">
           <item name="config" xsi:type="array">
               <item name="label" xsi:type="string" translate="true">Custome enable</item>
               <item name="sort_order" xsi:type="string">1</item>
           </item>
       </argument>
       <field name="enable">
           <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">select</item>
                   <item name="label" xsi:type="string">Customer</item>
                   <item name="options" xsi:type="array">
                       <item name="20" xsi:type="array">
                           <item name="value" xsi:type="number">1</item>
                           <item name="label" xsi:type="string" translate="true">Yes</item>
                       </item>
                       <item name="30" xsi:type="array">
                           <item name="value" xsi:type="number">0</item>
                           <item name="label" xsi:type="string" translate="true">No</item>
                       </item>
                   </item>
               </item>
           </argument>
       </field>
   </fieldset>
</form>

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.