Commit 6da2eebf by Carsten Brandt

Merge pull request #3676 from enigmatix/master

Added ability to generate dropdown from Enum field
parents a643bde5 25fa2f2d
......@@ -247,7 +247,13 @@ class Generator extends \yii\gii\Generator
} else {
$input = 'textInput';
}
if ($column->phpType !== 'string' || $column->size === null) {
if (is_array($column->enumValues) && count($column->enumValues) > 0) {
$dropDownOptions = "'' => '', ";
foreach ($column->enumValues as $enumValue) {
$dropDownOptions .= "'".$enumValue."' => '".$enumValue."', ";
}
return "\$form->field(\$model, '$attribute')->dropDownList([".$dropDownOptions."])";
} else if ($column->phpType !== 'string' || $column->size === null) {
return "\$form->field(\$model, '$attribute')->$input()";
} else {
return "\$form->field(\$model, '$attribute')->$input(['maxlength' => $column->size])";
......
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