Craft CMS Asked by johirpro on September 4, 2021
Following code is working on Craft 2:
class My_TableRecord extends BaseRecord {
public function getTableName() {
return 'my_table';
}
protected function defineAttributes() {
return [
'title' => AttributeType::String,
'description' => AttributeType::Mixed
];
}
}
According to this documentation the defineAttributes() is not available in Craft 3. So how can I define table’s attributes in Craft3 to complete following code:
class My_TableRecord extends ActiveRecord
{ public static function tableName()
{
return '{{%my_table}}';
}
//equivalent function of defineAttributes() of Craft3 will go here
}
So how can I define table's attributes in Craft 3 to complete following code:
You don't.
By just defining the table name, that gives Yii enough information to reflect on the underlying columns for the table.
You can add property doc blocks to get type-hinting in your IDE for the columns.
Probably also worth reading: https://docs.craftcms.com/v3/extend/updating-plugins.html
Answered by Brad Bell on September 4, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP