Browse Source

Unique indexes rules for single columns into array

tags/2.0.0-beta
Luciano Baraglia 11 years ago
parent
commit
bdafb4becb
  1. 2
      extensions/yii/gii/generators/model/Generator.php

2
extensions/yii/gii/generators/model/Generator.php

@ -255,7 +255,7 @@ class Generator extends \yii\gii\Generator
foreach ($uniqueIndexes as $indexName => $uniqueColumns) { foreach ($uniqueIndexes as $indexName => $uniqueColumns) {
$attributesCount = count($uniqueColumns); $attributesCount = count($uniqueColumns);
if ($attributesCount == 1) { if ($attributesCount == 1) {
$rules[] = "['" . $uniqueColumns[0] . "', 'unique']"; $rules[] = "[['" . $uniqueColumns[0] . "'], 'unique']";
} elseif ($attributesCount > 1) { } elseif ($attributesCount > 1) {
$labels = array_intersect_key($this->generateLabels($table), array_flip($uniqueColumns)); $labels = array_intersect_key($this->generateLabels($table), array_flip($uniqueColumns));
$lastLabel = array_pop($labels); $lastLabel = array_pop($labels);

Loading…
Cancel
Save