"how to add an admin form customer email dropdown in magento 2" Code Answer's

You're definitely familiar with the best coding language PHP that developers use to develop their projects and they get all their queries like "how to add an admin form customer email dropdown in magento 2" answered properly. Developers are finding an appropriate answer about how to add an admin form customer email dropdown in magento 2 related to the PHP coding language. By visiting this online portal developers get answers concerning PHP codes question like how to add an admin form customer email dropdown in magento 2. Enter your desired code related query in the search bar and get every piece of information about PHP code related question on how to add an admin form customer email dropdown in magento 2. 

how to add an admin form customer email dropdown in magento 2

By Amused AlligatorAmused Alligator on Feb 02, 2021
<?php
namespace Webkul\Test\Ui\Component\Create\Form\Customer;
 
use Magento\Framework\Data\OptionSourceInterface;
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory;
use Magento\Framework\App\RequestInterface;
 
/**
 * Options tree for "Categories" field
 */
class Options implements OptionSourceInterface
{
    /**
     * @var \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory
     */
    protected $customerCollectionFactory;
 
    /**
     * @var RequestInterface
     */
    protected $request;
 
    /**
     * @var array
     */
    protected $customerTree;
 
    /**
     * @param CustomerCollectionFactory $customerCollectionFactory
     * @param RequestInterface $request
     */
    public function __construct(
        CustomerCollectionFactory $customerCollectionFactory,
        RequestInterface $request
    ) {
        $this->customerCollectionFactory = $customerCollectionFactory;
        $this->request = $request;
    }
 
    /**
     * {@inheritdoc}
     */
    public function toOptionArray()
    {
        return $this->getCustomerTree();
    }
 
    /**
     * Retrieve categories tree
     *
     * @return array
     */
    protected function getCustomerTree()
    {
        if ($this->customerTree === null) {
            $collection = $this->customerCollectionFactory->create();
 
            $collection->addNameToSelect();
 
            foreach ($collection as $customer) {
                $customerId = $customer->getEntityId();
                if (!isset($customerById[$customerId])) {
                    $customerById[$customerId] = [
                        'value' => $customerId
                    ];
                }
                $customerById[$customerId]['label'] = $customer->getName();
            }
            $this->customerTree = $customerById;
        }
        return $this->customerTree;
    }
}

Source: webkul.com

Add Comment

0

how to add an admin form customer email dropdown in magento 2

By Amused AlligatorAmused Alligator on Feb 02, 2021
define([
    'Magento_Ui/js/form/element/ui-select'
], function (Select) {
    'use strict';
    return Select.extend({
        /**
         * Parse data and set it to options.
         *
         * @param {Object} data - Response data object.
         * @returns {Object}
         */
        setParsed: function (data) {
            var option = this.parseData(data);
            if (data.error) {
                return this;
            }
            this.options([]);
            this.setOption(option);
            this.set('newOption', option);
        },
        /**
         * Normalize option object.
         *
         * @param {Object} data - Option object.
         * @returns {Object}
         */
        parseData: function (data) {
            return {
                value: data.customer.entity_id,
                label: data.customer.name
            };
        }
    });
});

Source: webkul.com

Add Comment

0

how to add an admin form customer email dropdown in magento 2

By Amused AlligatorAmused Alligator on Feb 02, 2021
<field name="customer" component="Webkul_Test/js/components/select-customer" sortOrder="20" formElement="select">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="filterOptions" xsi:type="boolean">true</item>//to add filter in select-ui
            <item name="multiple" xsi:type="boolean">false</item>//select multiple or not
            <item name="showCheckbox" xsi:type="boolean">true</item>
            <item name="disableLabel" xsi:type="boolean">true</item>
        </item>
    </argument>
    <settings>
        <required>true</required>
        <validation>
            <rule name="required-entry" xsi:type="boolean">true</rule>
        </validation>
        <elementTmpl>ui/grid/filters/elements/ui-select</elementTmpl>
        <label translate="true">Select Customer</label>//label to Field
        <dataScope>data.customer</dataScope>//To map
        <componentType>field</componentType>
        <listens>
            <link name="${ $.namespace }.${ $.namespace }:responseData">setParsed</link>
        </listens>
    </settings>
    <formElements>
        <select>
            <settings>
                <options class="Webkul\Test\Ui\Component\Create\Form\Customer\Options"/>
            </settings>
        </select>
    </formElements>
</field>

Source: webkul.com

Add Comment

0

All those coders who are working on the PHP based application and are stuck on how to add an admin form customer email dropdown in magento 2 can get a collection of related answers to their query. Programmers need to enter their query on how to add an admin form customer email dropdown in magento 2 related to PHP code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to add an admin form customer email dropdown in magento 2 for the programmers working on PHP code while coding their module. Coders are also allowed to rectify already present answers of how to add an admin form customer email dropdown in magento 2 while working on the PHP language code. Developers can add up suggestions if they deem fit any other answer relating to "how to add an admin form customer email dropdown in magento 2". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to add an admin form customer email dropdown in magento 2 resolved professionally and stay updated to the latest PHP updates. 

PHP answers related to "how to add an admin form customer email dropdown in magento 2"

View All PHP queries

PHP queries related to "how to add an admin form customer email dropdown in magento 2"

Browse Other Code Languages

CodeProZone