Hi Magento friend today's i'm share How to get coustomer Email List option in ui component form
In Uicomponent create a field -
How we are Integrate the coustomer Email List options in uicomponent Form -
<field name="customer_email" formElement="select">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">vendor_name\module_name\Model\Options\CustomerEmail</item>
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">text</item>
<item name="label" translate="true" xsi:type="string">Select Email</item>
<item name="formElement" xsi:type="string">multiselect</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
</argument>
</field>
<?phpnamespace vendor_name\module_name\Model\Options;use Magento\Framework\Option\ArrayInterface;class CustomerEmail implements ArrayInterface {protected $_customers;public function __construct(\Magento\Customer\Model\Customer $customers) {$this->_customers = $customers;}public function toOptionArray() {$customersdata = $this->_customers->getCollection()->addAttributeToSelect("*")->load();foreach ($customersdata as $data) {$customername = $data->getData('firstname') . " " . $data->getData('lastname');$customeremail = $data->getData('email');$this->_options[] = ['label' => $customeremail, 'value' => $customeremail];}return $this->_options;}}
Nice Post Bro
ReplyDelete