Get Free Audit

Dynamic Settings Array in Magento 2.0

Feb 22, 2016

5090 Mishel Soiko

Dynamic Settings Array in Magento 2.0

In order to save dynamic settings array in one field, a default FieldArray is used.

Navigate to:

Stores => Configuration => Catalog => Inventory

Dynamic Settings Array in Magento 2.0

This is really convenient.

Such a field can be useful for any options list that is being extended. You can add new and delete existing options.

Here is how I define ranges.

Dynamic Settings Array in Magento 2.0

But it’s also possible to use it for displaying dynamic lists with editable content. In our case, it is used in the Product Sorting extension to display generated sortings.

Dynamic Settings Array in Magento 2.0

So let’s check the details of the example, as here we make multiple changes to the default field.

I had to add several custom fields such as: checkbox, link.

magento custom development

Magento Custom Development

Take your online store to the next level with BelVG Magento Custom Development

Visit the page

Let’s check how to use it:

Create a new Field in system.xml


It’s kind of easy: in the block, you describe your table, and the model influences the saving process.


Our block should contain the following:


This is a basis that is necessary to create and influence the saving process.

Let’s check the details of the AbstractFieldArray and find out what it can do.

In the previous example, a separate renderer could be created for each column. If the renderer was false, an empty field <input /> would be created.

Igor Dragun
Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Igor


And the renderer block that describes our new field. In this particular case it describes the checkbox.


The column can have a few more described parameters except label and renderer.

They are default in renderer. And we added them for our checkbox: style, class, size.


In the AbstractFieldArray class you can also find a function for customizing the saved fields.


In this article we checked an array as a default field.

You can also check this article to find out about creating unique fields and how they can be improved by using jQuery UI.

groups_catalog

Groups Catalog for Magento 2

Take your online store to the next level with BelVG module

Download here

Keep track of your unregistered visitors with this free Magento extension from BelVG.

Igor Dragun
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Igor

2 Comments

  1. Hi Chandresh,

    In general, this module is for creating configurations and uses the standard Magento functionality. For the minimum quantity of products in cart, there are default settings for each product.

  2. I have to create configuration like Minimum quantity allowed in cart with one additional field. How can i create like that in default magento 2?

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *