The reference table here states the following regarding the options node: "Not used. Potentially deprecated."
Furthermore, the warning box below states the following: "...and options are defined by a different core payment model and are only used once. These nodes are not reusable."
However, I have found that if the field is of type="select", the options node works, and seems to be a rather nice approach for providing source options without having to build out a PHP class for it.
<field id="foo_bar" type="select" showInDefault="1">
<label>Can We Use This?</label>
<options>
<option label="We can certainly use this">w00t</option>
<option label="No do not use this">sad_face</option>
</options>
</field>
The inner text of each option tag above gets populated into the value attribute of the select node's option tag on the page. And as one would suspect, the label attribute of the option tag gets populated into the inner text of the option tag on the page.
Possible solutions
If this is "potentially deprecated" as the description states, I'd like to see where in the source code it states this (I admit I haven't looked myself). At a minimum, the statement "these nodes are not reusable" (at the moment) is false in regards to options.
If this functionality is not deprecated, the following description may be appropriate:
Can be used to declare options where source_model is not defined. Is used to only when a given field has a type of select. This node expects option child node(s).
Additional information
I take no issue with writing out the usual PHP model that implements the appropriate interface. But also see value in providing developers the ability to configure options here if it is a feature that is going to stay. The current documentation is vague, "Potentially deprecated" seems rather meaningless to me. Something is either deprecated or it is not.
Topic clarification/correction request
Topic Link
https://devdocs.magento.com/guides/v2.4/config-guide/prod/config-reference-systemxml.html#field-node-reference
Description
options
node: "Not used. Potentially deprecated."options
are defined by a different core payment model and are only used once. These nodes are not reusable."However, I have found that if the field is of
type="select"
, the options node works, and seems to be a rather nice approach for providing source options without having to build out a PHP class for it.The inner text of each
option
tag above gets populated into thevalue
attribute of the select node'soption
tag on the page. And as one would suspect, thelabel
attribute of the option tag gets populated into the inner text of theoption
tag on the page.Possible solutions
If this is "potentially deprecated" as the description states, I'd like to see where in the source code it states this (I admit I haven't looked myself). At a minimum, the statement "these nodes are not reusable" (at the moment) is false in regards to
options
.If this functionality is not deprecated, the following description may be appropriate:
Additional information
I take no issue with writing out the usual PHP model that implements the appropriate interface. But also see value in providing developers the ability to configure options here if it is a feature that is going to stay. The current documentation is vague, "Potentially deprecated" seems rather meaningless to me. Something is either deprecated or it is not.