Reading list Switch to dark mode

    Magento 2:- How to Create Radio button in Admin System Configuration

    Updated 29 September 2022

    Hello guys!!

    In this article, we will learn how to create a radio button in admin Configuration.
    Magento does provide the type to create a radio type field but if you use it, it will only show a single radio button without any title or value to save, So it requires a little custom task to make it look understandable and working.

    Let’s do it!!

    First, we will create a system.xml


    <?xml version="1.0"?>
    <config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
            <tab id="webkul" translate="label" sortOrder="100">
            <section id="demo" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
                <group id="general" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>General Setting</label>
                    <field id="enable" translate="label" type="radios" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">

    Note:- Field type is radios, not radio

    Start your headless eCommerce
    Find out More

    Let’s create our custom source model.


    namespace Webkul\Demo\Model\Config\Source;
    class Radio implements \Magento\Framework\Data\OptionSourceInterface
         * To option array
        public function toOptionArray()
            return [
                ['value' => 1, 'label' => __('Enable')],
                ['value' => 0, 'label' => __('Disable')]

    That’s all for this article. Let me know if this was helpful. Thank you for your time.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*

    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home