Having a backend_model
specified, a backend config form field can employ a custom logic for a config value loading and saving.
An example:
A backend model should implement the \Magento\Framework\App\Config\ValueInterface
interface:
Magento 2 checks whether the interface is implemented:
Step 1. Magento\Config\Block\System\Config\Form::getFieldData()
Step 2. Magento\Config\Model\Config\Structure\Element\Field::getBackendModel()
Step 3. Magento\Config\Model\Config\BackendFactory::create()
But implementing the \Magento\Framework\App\Config\ValueInterface
is not enough for a backend_model
: Logical error: Magento 2 checks whether a backend config form field’s «backend_model» implements the \Magento\Framework\App\Config\ValueInterface interface only, but actually calls the «backend_model» for much more methods (absent in the interface).
Usually a backend_model
is an instance of the \Magento\Framework\App\Config\Value
class.