yii2-mongodb
yii2-mongodb copied to clipboard
Erros generating crud with gii
What steps will reproduce the problem?
- Install yii2
- Connect to a MongoDB database
- Create a mongodb model
- Open GII web interface and choose CRUD
What's expected?
- I should get the generated crud code without any errors
What do you get instead?
- I get the error:
Call to undefined method common\models\mongo\Lab::getTableSchema()
Additional info
This is the code causing the error and it is part of https://github.com/yiisoft/yii2-gii package actually, but I'm not sure if the error comes from Gii or this extension needs some tweaking so it doesn't show up.
/**
* Returns table schema for current model class or false if it is not an active record
* @return \yii\db\TableSchema|false
*/
public function getTableSchema()
{
$class = $this->modelClass;
if (is_subclass_of($class, '\yii\db\BaseActiveRecord')) {
return $class::getTableSchema();
}
return false;
}
What I did see is that in the past it worked, but Gii was updated and it stopped working. Previously the code was:
if (is_subclass_of($class, '\yii\db\ActiveRecord')) {
So as a workaround if you swap one line with the other it works. But again this is Gii code.
Also second lighter error
- If you manage to finally generate the code, this error shows when running the
create
action:Calling unknown method: common\models\mongo\Lab::loadDefaultValues()
Q | A |
---|---|
Yii version | 2.0.51 |
Yii MongoDB version | 3.0.1 |
Gii version | 2.2.6 |
MongoDB server version | MongoDB 7.3.3 Atlas |
PHP version | 8.1.19 |
Operating system | Windows 11 Pro |