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">
<label>Reasons</label>
<frontend_model>Sundaysea\Test\Block\Adminhtml\Form\Field\Properties</frontend_model>
</field>
And in Sundaysea\Test\Block\Adminhtml\Form\Field\Properties class you should make it extends from
\Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
And override the function _prepareToRender
protected function _prepareToRender()
{
$this->addColumn(
'value',
[
'label' => __('Value'),
]
);
$this->_addAfter = false;
$this->_addButtonLabel = __('Add Rule');
}
And in configuration section, it will end up like this
