octicon-rss(16/)
You've already forked yii2
mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-10 23:50:38 +08:00
Merge pull request #3676 from enigmatix/master
Added ability to generate dropdown from Enum field
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
octicon-diff(16/tw-mr-1) 1 changed files with 7 additions and 1 deletions
@@ -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])";
|
||||
|
||||
Reference in New Issue
Block a user