Commit faed08e6 by Carsten Brandt

fixed crud to work with table that has no PK but AR defines one

parent 183a0bfa
...@@ -341,7 +341,9 @@ class Generator extends \yii\gii\Generator ...@@ -341,7 +341,9 @@ class Generator extends \yii\gii\Generator
public function generateUrlParams() public function generateUrlParams()
{ {
$pks = $this->getTableSchema()->primaryKey; /** @var ActiveRecord $class */
$class = $this->modelClass;
$pks = $class::primaryKey();
if (count($pks) === 1) { if (count($pks) === 1) {
return "'id' => \$model->{$pks[0]}"; return "'id' => \$model->{$pks[0]}";
} else { } else {
...@@ -355,7 +357,9 @@ class Generator extends \yii\gii\Generator ...@@ -355,7 +357,9 @@ class Generator extends \yii\gii\Generator
public function generateActionParams() public function generateActionParams()
{ {
$pks = $this->getTableSchema()->primaryKey; /** @var ActiveRecord $class */
$class = $this->modelClass;
$pks = $class::primaryKey();
if (count($pks) === 1) { if (count($pks) === 1) {
return '$id'; return '$id';
} else { } else {
...@@ -366,7 +370,9 @@ class Generator extends \yii\gii\Generator ...@@ -366,7 +370,9 @@ class Generator extends \yii\gii\Generator
public function generateActionParamComments() public function generateActionParamComments()
{ {
$table = $this->getTableSchema(); $table = $this->getTableSchema();
$pks = $table->primaryKey; /** @var ActiveRecord $class */
$class = $this->modelClass;
$pks = $class::primaryKey();
if (count($pks) === 1) { if (count($pks) === 1) {
return ['@param ' . $table->columns[$pks[0]]->phpType . ' $id']; return ['@param ' . $table->columns[$pks[0]]->phpType . ' $id'];
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment