Comments (12)
Can you show me the error?
from yii2-enhanced-gii.
These 2 images below are the error.
from yii2-enhanced-gii.
Please show me the full error, generated models, & SQLs..
from yii2-enhanced-gii.
this is because you don't setup the foreign key of table_a_id column
at table_b
from yii2-enhanced-gii.
I'm having the same issue. This occurs when your tables have composite names, like my_table1.
So, for example, in crud\Generator.php
in method generateGridViewFieldIndex
, about line 941 you have:
$modelRel = $rel[2] ? Inflector::pluralize($rel[3]) : $rel[3];
$output = "[
'attribute' => '$attribute',
'label' => " . $this->generateString(ucwords(Inflector::humanize($rel[5]))) . ",
'value' => function(\$model){
return \$model->$modelRel->$labelCol;
},
'filterType' => GridView::FILTER_SELECT2,
'filter' => \\yii\\helpers\\ArrayHelper::map(\\$this->nsModel\\$rel[1]::find()->asArray()->all(), '$rel[4]', '$labelCol'),
'filterWidgetOptions' => [
'pluginOptions' => ['allowClear' => true],
],
'filterInputOptions' => ['placeholder' => '$humanize', 'id' => '$id']
],\n";
return $output;
Note that $modeRel
at line 941 is set to pluralize or the normal attribute pattern (with underscore separating words). But at line 946 it should be in variablize pattern (with camelcase separating words).
In the case above we can fix the issue by changing the line 946 to:
$modelRel = $rel[2] ? Inflector::pluralize($rel[3]) : Inflector::variablize($rel[3]);
The same can be done in generateDetailViewField
method, about line 826, that get fixed by replacing these lines:
$output = "[
'attribute' => '$rel[3].$labelCol',
'label' => " . $this->generateString(ucwords(Inflector::humanize($rel[5]))) . ",
with these lines:
$modelRel = $rel[2] ? Inflector::pluralize($rel[3]) : Inflector::variablize($rel[3]);
$output = "[
'attribute' => '$modelRel.$labelCol',
'label' => " . $this->generateString(ucwords(Inflector::humanize($rel[5]))) . ",
I'm testing it by now, but it seems that the issue is cleared.
from yii2-enhanced-gii.
Please test @dev version. Is dev version is still generate the same error?
from yii2-enhanced-gii.
Yes. I'm using the @dev version.
from yii2-enhanced-gii.
from yii2-enhanced-gii.
Yes, the error still occurs in @dev version. You have to fix the code mentioned above in order to fix the issue.
from yii2-enhanced-gii.
could you give me your sqldump? I've tested @dev version with http://downloads.mysql.com/docs/sakila-db.zip database. And when I generate actors, film-actors, and films (many-many relationship / film-actors have composite pk), it's fine.
from yii2-enhanced-gii.
Great!! it seems to be working now.
Although it still stucks in self-referenced tables. But everything else is just fine.
from yii2-enhanced-gii.
from yii2-enhanced-gii.
Related Issues (20)
- In model generator tinyint create rules as string
- No results found. HOT 1
- Error when the instance of a model is created - Softdelete and Blameable Behavior HOT 1
- Custom Model Template HOT 1
- PHP version HOT 1
- wrong table name generated when table name has "_" in it HOT 1
- When I updated the master record, the child record on all related tables is soft deleted. HOT 1
- Generate migration column tinyint give error result
- Can't detect if in the model function beforesave the object is soft deleted HOT 1
- "Call to a member function getColumnNames() on null" HOT 1
- Open redirect in crud/default/views/_form.php HOT 2
- Models and CRUD generation in batch command HOT 1
- Edit Generator Code HOT 3
- PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: HOT 2
- Model generation getRelations() bug
- Auto increment primary keys fails HOT 3
- bit, tinyint to boolean
- deletedByValueRestored is always 0
- HasMany: Update > valdiation error Message > update again >The object being updated is outdated. HOT 1
- Switch to twig or another templating engine? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yii2-enhanced-gii.