I have written a custom widget. It's run on my local installation (1.8.1), but not in my remote installation (same system).

If i select my widget from the select box i get a fatal error:

Fatal error: Call to a member function toOptionArray() on a non-object in /var/www/vhosts/.../.../app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php on line 171

That is my ChooserModel, located in app/code/local/[Namespace]/[Module]/Model/ChooserCategories.php:

class [Namespace]_[Module]_Model_ChooserCategories {

    public function toOptionArray() {


        if (Mage::registry('[Namespace]_[Module]_Model_ChooserCategories_value')) {

            $arrOptions = Mage::registry('[Namespace]_[Module]_Model_ChooserCategories_value');

        } else {

            $objCategories = Mage::getModel('catalog/category')->getCollection();

            $arrOptions = array();
            $arrOption = array();

            $arrOption['label'] = '(no filter)';
            $arrOption['value'] = 'none';

            array_push($arrOptions, $arrOption);

            foreach ($objCategories as $objCategory) {


                $arrOption = array();
                $arrOption['label'] = str_repeat("---", $objCategory->getLevel()) . ' ' . $objCategory->getName();
                $arrOption['value'] = $objCategory->getId();

                array_push($arrOptions, $arrOption);


            Mage::register('[Namespace]_[Module]_Model_ChooserCategories_value', $arrOptions);


        return $arrOptions;



On line 171 in app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php try magento to load the source_model by name. It's look like magento have the model not loaded. If i return the model-name i get the correct one:


Take a look into the config.xml for the module:

<?xml version="1.0"?>

Can anybody find the bug, or does someone have a tip for me?


1 Answer 1


name your file Choosercategories.php instead of ChooserCategories.php (make c in categories lowercase) and the class name should change accordingly.

Namespace]_[Module]_Model_ChooserCategories becomes Namespace]_[Module]_Model_Choosercategories

Your Answer

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

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