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" 

my new source model

//file app/code/TahirYasin/Hello/Model/Config/Source/Custom.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

  • Finally I ran the command $ 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. Commented Oct 10, 2017 at 8:19

3 Answers 3

public function toOptionArray()
    return [
        ['value' => 'val1', 'label' => __('Label 1')],
        ['value' => 'val2', 'label' => __('Label 2')]

Add options to the arrays

  • replaced toOptionArray function with provided code but that did not help either. Commented Oct 10, 2017 at 7:52

Your class name in the source_model is not the same like the class name. Has to be

  • thanks for your answer, actually I pasted wrong path while posting question, I updated my question please have a look Commented Oct 9, 2017 at 16:29

Hello I have perfect solution which will work 100 % ., You have to define only in system.xml .


If you have any query let me know .

  • can you guys please answer of this link ...its related to <resource model > how render model/shipem.php and bind with yes/no button. i am not getting exact solution till now .magento.stackexchange.com/questions/296553/…
    – irshad
    Commented Nov 22, 2019 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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