Create a repeatable configuration field in Magento 2

Sometime you want a configuration field to have multiple value, and you want to make it easy for administrators to input instead of separating values by delimiter like commas. You can use frontend_model to make a repeatable field

For example in system.xml you can do like this

<field id="reasons" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
And in Sundaysea\Test\Block\Adminhtml\Form\Field\Properties class you should make it extends from 

And override the function _prepareToRender

protected function _prepareToRender()
            'label'     => __('Value'),
    $this->_addAfter = false;
    $this->_addButtonLabel = __('Add Rule');

And in configuration section, it will end up like this

Trả lời