I have a module:
Model/SelectType.php
class NAME_CustomField_Model_SelectType
{
public function toOptionArray()
{
return array(
array('value' => '1', 'label' => '1'),
array('value' => '2', 'label' => '2'),
array('value' => '3', 'label' => '3'),
);
}
}
in my etc/config.xml I have:
<config>
<modules>
<NAME_CustomField>
<version>0.1.1</version>
</NAME_CustomField>
</modules>
<global>
<models>
<customfield>
<class>NAME_CustomField_Model</class>
</customfield>
</models>
</global>
...
Now, if I set in the DB (table: eav_attribute) source_model to: customfield/selectType
it gives an error: Source model "customfield/selectType" not found.
UPDATE:
I've moved my file to: "code/core/Mage/Customer/Model/Customer/Attribute/Source
" (for testing ofcourse) and changed the resource model to: customer/customer_attribute_source_selecttype
This works, so I think there is something in my /etc/*.xml that is wrong, but I can't seem to find what it would be… :-S
Best Answer
Your XML looks correct — although if Magento's loading the class from the
Mage
namespace that may be because your XML hasn't been loaded into the global configuration tree (cached XML, incorrectapp/etc/modules
file).Your best bet is to debug things at the point where Magento looks into the configuration for your new class name
Figure out why Magento can't find your base classname in the XML configuration, and you'll have your problem solved.