🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Allow Null Value in Multiselect System Configuration in Magento 2

By Sanjay JethvaUpdated on May 21, 2025 3 min read

Ever used multiselect box in Magento 2 system configuration to avail the admin multi selection ability for some setting?

There are many circumstances when the merchants do not wish to select the value and want to have a null value in the multi select box in system configuration. For instance, you have added a day selector named “Non-Deliverable Days” to select the days of the week when the delivery is unavailable. But, during the holiday season, the admin wishes to deliver products on all the days of the week and thus requires to unselect all the values from the days selector.

By default, multiselect box works fine with saving multiselect values in the database but when the admin unselects all the selected multiselect values, it saves recently saved options from the database instead of clearing the options from the database. Thus, the admin can never allow null value in multiselect system configuration in Magento 2.

Before adding can be empty tag in multiselect box

Follow the solution below to allow null value in multiselect system configuration in Magento 2.

Solution to Allow Null Value in Multiselect System Configuration in Magento 2

1. For example, you have created a system.xml file at app/code/Vendor/Module/etc/adminhtml to add a multiselect box in system configuration.

<?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>
        <section id="extension_name">
            <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1"
                   showInStore="1">
                <field id="disable_delivery_date" translate="Disable Delivery Date" type="multiselect" sortOrder="8"
                       showInDefault="1" showInWebsite="1"
                       showInStore="1">
                    <label>Non-Deliverable Days</label>
                    <source_model>Vendor\Module\Ui\Component\Listing\column\Multiselect</source_model>
                </field>
            </group>
        </section>
    </system>
</config>

2.Magento 2 has the below property to allow null value in multiselect. Add the <can_be_empty> tag in the code to serve your purpose.

 <can_be_empty>1</can_be_empty>
After adding can be empty tag in multiselect box

Behind the scenes, when you set can_be_empty to 1 (true), the system renders a hidden field on the System Configuration page.

Please do consider sharing this post with Magento Community via social media.

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.