Magento 2 admin panel offers multiple input types such as text box, radio button, dropdown, multi-select boxes, etc. The input values of these fields are stored and displayed in different forms of grids, forms, fields, images, etc.
Sometimes, while developing Magento 2 extensions, or custom features, developers often need to provide an option to choose days of the week to exclude or include in the module’s functionalities.
For example, the feature for the admin to select the days of the week when a customer can book an appointment, or select the days on which the store will offer delivery.
Even when you want the store admin to monitor the days off as per the business requirements, the above solution is helpful.
In all these cases, you need to get week days list in Magento 2 system configuration as shown below:
If you face a similar requirement, feel free to use the below solution:
Method to Get Week Days List in Magento 2 System Configuration
Use the below code in the system.xml at app/code/Meetanshi/CustomerAppointment/etc/adminhtml
<field id="week_days" translate="label" type="multiselect" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
Simple. Isn’t it?
That’s it to get the weekdays list in Magento 2 system configuration.
Any doubts can be mentioned in the Comments section below and I’d be happy to help!
Do share the solution with fellow developers via social media.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.