---
title: "Add custom select option into system configuration using system.xml Magento 2"
url: "https://dolphinwebsolution.com/how-to-add-custom-select-option-into-system-xml-magento-2"
date: "2021-03-24T05:36:52+05:30"
modified: "2023-08-31T05:22:36+05:30"
author:
  name: "Mahesh Makwana"
categories:
  - "Magento"
word_count: 478
reading_time: "3 min read"
summary: "We learn how to add custom option option in system configuration using system.xml file. First we need to create a Basic module, and after create module add below code to your system.xml file. Examp..."
description: "We learn how to add custom select option in system configuration using system.xml file. First, we need to create a Basic module, and after creating the modul..."
keywords: "Add custom select option, add custom select drop down option, custom select option, add custom select drop down option into system configuration Magento 2, Magento"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How To Add Split Button on Admin Page in Magento 2"
    url: "https://dolphinwebsolution.com/how-to-add-split-button-on-admin-page"
  - title: "Magento Development Services: Everything You Need to Know for Your Online Store"
    url: "https://dolphinwebsolution.com/blog/everything-need-to-know-about-magento-development-services/"
  - title: "How to Add Custom Block to Order View Information in Magento"
    url: "https://dolphinwebsolution.com/add-custom-block-to-order-view-information-in-magento"
---

# Add custom select option into system configuration using system.xml Magento 2

_Published: March 24, 2021_  
_Author: Mahesh Makwana_  

![](https://dolphinwebsolution.com/wp-content/uploads/2023/02/system-configuration-1024x512.jpg)

> We learn how to add custom option option in system configuration using system.xml file. First we need to create a Basic module, and after create module add below code to your system.xml file. Example, We will get and display all admin name into system.xml in System -> Configuration -> Dolphin Section of admin. app/code/Dolphin/BasicModule/etc/adminhtml/system.xml

We learn how to [add custom select option](https://dolphinwebsolution.com/shop/product-custom-option-templates-for-magento.html) in system configuration using system.xml file.

First, we need to create a [Basic module](https://dolphinwebsolution.com/how-to-create-module-in-magento-2), and after create the module add below code to your system.xml file.

For example, We will get and display all admin names into system.xml in **System -> Configuration -> Dolphin** Section of admin.

**app/code/Dolphin/BasicModule/etc/adminhtml/system.xml**

```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <tab id="dolphin" translate="label" sortOrder="201">
            <label>Dolphin</label>
        </tab>
                    <class>separator-top</class>
            <label>Basic Module</label>
            <tab>dolphin</tab>
            <resource>Dolphin_BasicModule::basicmodule_config</resource>
            <group id="genaral_setting"
                   translate="label"
                   type="text"
                   sortOrder="10"
                   showInDefault="1"
                   showInWebsite="1"
                   showInStore="1">
                <label>General Settings</label>
                <field id="admin_list"
                       translate="label"
                       type="select"
                       sortOrder="10"
                       showInDefault="1"
                       showInWebsite="1"
                       showInStore="1">
                    <label>Select Admin</label>
                    <source_model>Dolphin\BasicModule\Model\Adminhtml\System\Config\Source\AdminUser</source_model>
                    <comment><![CDATA[Comment are <b>write here</b>.]]></comment>
                </field>
            </group>
            </system>
</config>
```

Here **source\_model** tag in system.xml is defined your model PHP file, which shows your custom options. Now create **AdminUser.php** file.

**app/code/Dolphin/BasicModule/Model/Adminhtml/System/Config/Source/AdminUser.php**

```
<?php

namespace Dolphin\BasicModule\Model\Adminhtml\System\Config\Source;

use Magento\User\Model\ResourceModel\User\CollectionFactory as UserCollectionFactory;

class AdminUser implements \Magento\Framework\Option\ArrayInterface
{
    protected $_userFactory;

    public function __construct(
        UserCollectionFactory $userFactory
    ) {
        $this->_userFactory = $userFactory;
    }

    public function getOptionArray()
    {
        $adminUsers = $this->_userFactory->create();
        $options = [];
        foreach ($adminUsers as $adminUser) {
            $options[$adminUser->getId()] = __($adminUser->getUsername());
        }
        return $options;
        /*
        // you can add this way also
        $options = [];
        $options[] = __('Admin 1');
        $options[] = __('Admin 2');
        $options[] = __('Admin 3');
        return $options;
        */
    }

    public function getAllOptions()
    {
        $res = $this->getOptions();
        array_unshift($res, ['value' => '', 'label' => '']);
        return $res;
    }

    public function getOptions()
    {
        $res = [];
        foreach ($this->getOptionArray() as $index => $value) {
            $res[] = ['value' => $index, 'label' => $value];
        }
        return $res;
    }

    public function toOptionArray()
    {
        return $this->getOptions();
    }
}
```

Clear Cache using **PHP bin/magento cache:flush** and check it now you can show your custom option into your system configuration. If your want Multi-Select option then simple add **type=”multiselect”** to <field> tag into [system.xml](https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/files/config-reference-systemxml.html) file.

Connect with Dolphin Web Solution for [**Magento 2 development.**](https://dolphinwebsolution.com/magento-2-development/)

I hope this helps you. For any doubts regarding this topic, please write your doubts in the comments section.


---

_View the original post at: [https://dolphinwebsolution.com/how-to-add-custom-select-option-into-system-xml-magento-2](https://dolphinwebsolution.com/how-to-add-custom-select-option-into-system-xml-magento-2)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-26 06:54:27 UTC_  
