I've created ui_component form where I need to show customer details, same as Customer Edit.
But, I am 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 displaystatus
(Customer Attribute).Now My Second attribute is
file
type. It's incustomer_entity_varchar
, Firstly I thought of adding another join but I think it's not the good way.
So, Is there any solution for this? I need to display both Customer Attributes
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 seem to be working.
Take a look at field
name that is value
for Status.
If I use the same thing for image field then image component disappears.
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 then most welcome.**