system.xml saved config validation in Magento 2
system.xml saved config validation in Magento 2 is possible via attaching a backend model to the field and validating the value server side.
Check Magento_Backend/etc/adminhtml/system.xml for the example:
1 2 3 4 5 |
<field id="base_url" translate="label comment" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Base URL</label> <backend_model>Magento\Config\Model\Config\Backend\Baseurl</backend_model> <comment>Specify URL or {{base_url}} placeholder.</comment> </field> |
There is the backend model in this field:
1 |
Magento\Config\Model\Config\Backend\Baseurl |
Consequently the method Magento\Config\Model\Config\Backend\Baseurl::beforeSave is called when saving the field.
Source: