In Magento 1.x you could have dynamic comments on system->configuration
fields by declaring your field in system.xml
like this:
<field_code_here translate="label">
<label>Label Here</label>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>
<model>[module]/field_comment</model><!-- this made it dynamic -->
</comment>
</field_code_here>
Then you just need to create the [Namespace]/[Module]/Model/Field/Comment.php
file with this content:
class [Namespace]_[Module]_Model_Field_Comment
{
public function getCommentText() //the method has to be named getCommentText
{
//do some calculations here
return 'Some string based on the calculations';
}
}
This way the field would have as comment what the getCommentText
method from above returned.
Is there an alternative for Magento 2? It seams that I cannot attach a model to a comment tag. The system.xml
is not validated by Magento/Backend/etc/system_file.xsd
if I do.
Enterprise_SalesArchive
module<comment><model>enterprise_salesarchive/system_config_backend_active</model></comment>
. because of this comment model I would see in thesystem->configuration
the number of archived orders. I've used this approach on numerous custom extensions and it worked on CE also. Obviously I cannot find a case in Magento 2. If I did I wouldn't be asking this question. I would just replicate that case.