I am trying to add a new configuration field to my module's configuration page that uses a custom source_model, as soon as I add the field to system.xml the whole configuration section goes blank. If I take out the field, the section works fine and shows other fields as expected.
//file app/code/TahirYasin/Hello/etc/adminhtml/system.xml
...
<field id="custom_select"
translate="label"
type="select"
sortOrder="2"
showInDefault="1"
showInWebsite="1"
showInStore="1">
<label>Scope</label>
<source_model>TahirYasin\Hello\Model\Config\Source\Custom</source_model>
</field>
...
my new source model
//file app/code/TahirYasin/Hello/Model/Config/Source/Custom.php
<?php
namespace TahirYasin\Hello\Model\Config\Source;
class Custom implements \Magento\Framework\Option\ArrayInterface
{
/**
* Return array of options as value-label pairs, eg. value => label
*
* @return array
*/
public function toOptionArray()
{
return [
'value' => 'Label',
'another_value' => 'Another value',
];
}
}
What am I doing wrong here? Any help plz
$ tree TahirYasin
and realized that the model was not present in my module's directory because I accidentally declared it inside another Magento instance having same module. Never mind.