1

I want to get the value and label both from the system.xml
I'm trying

etc/adminhtml/system.xml

<field id="link" translate="label" type="select"
                sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Link</label>
                <source_model>Vender\Module\Model\Config\Source\Link</source_model>
                <depends>
                    <field id="enabled">1</field>
                </depends>
            </field>

which returns me dropdown menu now when I get tried to get value from this function then its only return me the value but I also want the label as well how can I get both of these values?

  • where you want to get value? – Rohan Hapani Mar 12 at 8:51
  • You can set both the same. Otherwise, there is no standard way to get label also. – Ravi Mar 12 at 9:45
  • actually I'm getting this Link value in Helper n I can get it easily but the issue is I want to get both the Label n Value – Asad Khan Mar 12 at 13:30
1

Use \Magento\Framework\App\Config\ScopeConfigInterface::getValue to get the value.

In standard Magento2, you do not have a way to get the label

  • I get the values but the issue is I also want to get the label as well – Asad Khan Mar 12 at 9:08
  • In standard Magento2, you do not have a way to get the label – Philipp Sander Mar 12 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.