3

enter image description here

How can I populate this field so it's filled in when a customer creates an account? The value of the field just needs to match what customer[parent_customer_id] has. It doesn't necessarily have to happen on account creation.

enter image description here

The name of the field is customer[account_number]

This field is a duplicate but we call it something different and it populates correctly.

The name of that input is name="customer[parent_customer_id]"

Even though it's redundant I want both fields to populate. What file and where should I be editing to populate customer[account_number] in its respective field?

I just need the same default Attribute data that populates customer[parent_customer_id] to populate customer[account_number]

3
  • 1
    Not a hundred percent sure but I believe this is a DB value so it needs to be through UpgradeData
    – thismethod
    Mar 5, 2021 at 23:57
  • Can you please explain in more detail so that i can help you out Mar 6, 2021 at 11:57
  • customer[account_number] needs to populate two fields. @HarshJayswal
    – Singleton
    Mar 7, 2021 at 18:39

1 Answer 1

1

If I understand your question correctly you just want to have another field (account_number) to populate the same value of customer attribute parent_customer_id.

For this you will need to create a NameSpace/YourModule/view/adminhtml/ui_component/customer_form.xml and have this content:

<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="account_number" formElement="input">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">customer</item>
                </item>
            </argument>
            <settings>
                <dataType>text</dataType>
                <visible>true</visible>
                <label translate="true">Account Number</label>
                <dataScope>firstname</dataScope><!--change this "firstname" to "parent_customer_id". My understanding is parent_customer_id is a customer attribute.-->
            </settings>
        </field>
    </fieldset>
</form>

Hope this helps.

2
  • If you look at my inspect element picture above I already have the field customer[account_number] but just wish to populate it with parent_customer_id @Adarsh Khatri
    – Singleton
    Mar 11, 2021 at 15:56
  • Yes, I had seen your image. You will need to add this in your ui_component XML file: <dataScope>parent_customer_id</dataScope> like I have got it in the answer. Mar 11, 2021 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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