Commit 377b01d2 by João José

Typecast model Id so that urls don't break when using MongoDB object Id's

parent 665aefbb
...@@ -433,11 +433,11 @@ class Generator extends \yii\gii\Generator ...@@ -433,11 +433,11 @@ class Generator extends \yii\gii\Generator
$class = $this->modelClass; $class = $this->modelClass;
$pks = $class::primaryKey(); $pks = $class::primaryKey();
if (count($pks) === 1) { if (count($pks) === 1) {
return "'id' => \$model->{$pks[0]}"; return "'id' => (string)\$model->{$pks[0]}";
} else { } else {
$params = []; $params = [];
foreach ($pks as $pk) { foreach ($pks as $pk) {
$params[] = "'$pk' => \$model->$pk"; $params[] = "'$pk' => (string)\$model->$pk";
} }
return implode(', ', $params); return implode(', ', $params);
......
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