I'm trying to get a better understanding of how to define new models in plugins, but the documentation at http://buildwithcraft.com/docs/plugins/models doesn't get me very far.
For example, there is:
protected function defineAttributes()
{
return array(
'name' => AttributeType::String,
'type' => array(AttributeType::Enum, 'values' => "alcohol,mixer,other"),
);
}`
I've seen other plugins define attributes with an array element of 'required' => true
, but the only example I see here is 'values'
. Is there somewhere I can see a list of the available options when defining attributes? Or is it a better practice to define the attributes simply and then define validation rules in the rules()
method?
I know the docs say to check out the CModel documentation, but it doesn't even have defineAttributes. Does Craft itself have more in depth documentation on this topic?