0

I am facing issue of toOptionArray() in widget. I tried all of the way but not fixing this issue.

widget.xml

<?xml version="1.0"?>
<widgets>
    <modulename_article type="modulename/article" translate="name description" module="modulename">
        <name>Article</name>
        <description type="desc">Article</description>
        <parameters>
            <parameter1>
                <label>Brands</label>
                <visible>1</visible>
                <required>1</required>
                <type>multiselect</type>
<source_model>modulename/system_config_source_brands</source_model>
            </parameter1>
        </parameters>
    </modulename_article>
</widgets>

ModuleName\Model\System\Source\Brands.php

class Namespace_ModuleName_Model_System_Config_Source_Brands{

    public function toOptionArray(){
        $options =  array();

        $options[] = array(
            'value' => 'text',
            'label' => 'Only Text'
            );    
    }}

What is wrong in my code?

  • Hello there is a lot of possibility can you show yout config.xml (Model are defined as modulename)? – Mohamed El Mrabet Nov 9 at 7:07
0

You declaring your source model as

modulename/system_config_source_brands

but your model is missing the config folder. Please create a folder between system and source so it becomes

ModuleName\Model\System\Config\Source\Brands.php

or declare your source model to be

modulename/system_source_brands And modify class name to Namespace_ModuleName_Model_System_Source_Brands

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.