System.xml comment model not allowed by the validation schema
I'm trying to add a dynamic comment on a system.xml file.
In magento 1 this was possible by adding this on the field definion
<comment>
<model>[module]/field_comment</model><!-- this made it dynamic -->
</comment>
and creating the model class [Namespace]_[Module]_Model_Field_Comment that contains a public method getCommentText.
In Magento 2 this is not possible anymore because of the validation schema Magento/Backend/etc/system_file.xsd. In this schema the comment node has the type type="xs:string".
The odd think is that in the code that generates the form the case of a comment model is handled
Magento\Backend\Model\Config\Structure\Element\Field::getComment looks like this:
public function getComment($currentValue = '')
{
$comment = '';
if (isset($this->_data['comment'])) {
if (is_array($this->_data['comment'])) {
if (isset($this->_data['comment']['model'])) {
$model = $this->_commentFactory->create($this->_data['comment']['model']);
$comment = $model->getCommentText($currentValue);
}
} else {
$comment = parent::getComment();
}
}
return $comment;
}
So I guess you can bring back this functionality just by changing the type of the comment node.
Please bring it back. Even if it doesn't sound like much, I've used this a few times to present important messages for the admins directly in the configuration area.
@tzyganu, thank you for your request! We will consider the change you requested and will get back to you once we have a response.
Internal ticket: MAGETWO-31251
I see that this was merged in the develop branch. Thanks. I will close the issue.
is there any way to create field programically?
i want to add each payment one fee text box.