11

I've created ui_component form.

Where I need to show customer details, Same as Customer Edit.

But, I can able to show their data from customer_entity table.

DataProvider.php

public function getData()
{
    if (isset($this->loadedData)) {
        return $this->loadedData;
    }

    // {Vendor}\{Module}\Model\GridFactory 
    // Returns Customer Resource Model
    $items = $this->gridFactory->create()->getCollection();

   $items->getSelect()->join('customer_entity_text as second', 'main_table.entity_id = second.entity_id');
    //print_r($items->getData()); exit;
    foreach($items as $contact){
        $this->loadedData[$contact->getEntityId()]['contact'] = $contact->getData();
    }

    return $this->loadedData;
}

I've joined customer_entity_text table with my Factory in order to display status (Customer Attribute).

Now My Second attribute is file type. It's in customer_entity_varchar, Firstly I thought that to add another join but I think it's not the good way.

So, Is there any solution for this? I need to display both Customer Attribute in my form.

ui_component

<field name="value">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string">Status</item>
                <item name="visible" xsi:type="boolean">true</item>
                <item name="dataType" xsi:type="string">text</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">contact</item>
            </item>
        </argument>
    </field>

1). Above component is working good for Status but not for Profile Image that is Image type.

<field name="value">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string">Profile Image</item>
                <item name="visible" xsi:type="boolean">true</item>
                <item name="formElement" xsi:type="string">fileUploader</item>
                <item name="uploaderConfig" xsi:type="array">
                    <item name="url" xsi:type="url" path="path_controller"/>
                </item>
            </item>
        </argument>
    </field>

Even if I remove one field with same name form element it doesn't seems to be work.

Take a look at field name that is value for Status.

If I use the same thing for image field than image component is disappeared.

Note: I've no idea why Magento doesn't allow to use the name as value.

Cause I've joined in the collection so i am getting value as the array key.

**Question: How can I get customer attributes in this form without join in the collection ?

Also if you have other solution than most also most welcome.**

  • Can you check if the new attribute(s) you're using are in the Default attribute set of customer entity ? – obscure Jun 9 '18 at 7:34
  • Could you read your own question again: the question does not make sense to me when reading it. And therefore it does not help us to resolve your issue? – Herve Tribouilloy Jun 14 '18 at 8:42
  • Forget rest of things, If you can than answer for how can i display customer attributes in my custom ui form ? one is with Image and other one is text. – TBS Mage Jun 14 '18 at 9:54
  • is your question to build a form in the frontend or backend? – Herve Tribouilloy Nov 17 '18 at 15:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.