Magento 2 – Add Option for Custom Select Attribute on Customer Edit Page

customer-attributemagento2uicomponent

I want to add my own custom option for an attribute.Please see attached image.

enter image description here

Just guide me which files i need to create.

I have just created one file for now.
Please see code below,
app/code/Vendor/Module/view/base/ui_component/customer_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<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="ffl" formElement="select">
            <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>
            </settings>
        </field>
    </fieldset>
</form>

Best Answer

Try this,

<?xml version="1.0" encoding="UTF-8"?><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="custom_field" formElement="select">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="source" xsi:type="string">customer</item>
            </item>
        </argument>
        <formElements>
        <select>
            <settings>
                <options class="Vendor\Module\Model\Config\Source\Options"/>
            </settings>
        </select>
    </formElements>
        <settings>
            <dataType>text</dataType>
            <visible>true</visible>
        </settings>
    </field>
</fieldset>

In the options file, add the below code

<?php                                                                 
 namespace Vendor\Module\Model\Config\Source;                         
 class Options implements \Magento\Framework\Option\ArrayInterface            
 {
/**
 * Options for Type
 *
 * @return array
 */
public function toOptionArray()
{
    return [
        ['value' =>  1, 'label' => __('Type 1')],
        ['value' =>  2, 'label' => __('Type 2')],
        ['value' =>  3, 'label' => __('Type 3')]
    ];
}}

Hope this helps. Peace :)