How to Get Week Days List in Magento 2 System Configuration

How to Get Week Days List in Magento 2 System Configuration

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:

How to Get Week Days List in Magento 2 System Configuration

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

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.

Thanks.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 3 Reviews)

Dipak is a Magento Developer at Meetanshi. Apart from work, he loves playing cricket with his friends. Traveling and exploring new places is something that he is passionate about.

Leave a reply:

Your email address will not be published.