2016-05-12 144 views

回答

2

這是GII發生器的工作原理:

$model = new MyModel; // this is your model 
$tableSchema = $model->getTableSchema(); 
$column = $tableSchema->columns['my_column']; // the column that has enum values 

if (is_array($column->enumValues) && count($column->enumValues) > 0) { 
    $dropDownOptions = []; 
    foreach ($column->enumValues as $enumValue) { 
     $dropDownOptions[$enumValue] = \yii\helpers\Inflector::humanize($enumValue); 
    } 
} 

這將產生你$dropDownOptions與枚舉值。