O'Reilly logo

Magento 2 Development Cookbook by Bart Delvaux

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with source models

Magento works with a lot of dropdown fields that you can select in the forms of the application. We can see dropdowns in the configuration, product, customer, and many more pages.

Magento has a system to set the options of the dropdown and multiselect fields. Magento uses a model that returns the values and labels to render the options of a dropdown or multiselect field. These models are called source models.

In this recipe, we will see which source models Magento uses and how we can create a custom source model for a custom configuration field.

Getting ready

In this recipe, we will extend the Packt_HelloWorld module that we created in the previous recipes. Make sure you have the right version installed for this recipe. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required