/**
  * @return string
  */
 public function actionScaffold()
 {
     $model = new ScaffoldForm();
     if ($model->load(\Yii::$app->request->post()) and $model->validate()) {
         $params['name'] = $model->name;
         if ($model->path) {
             $params['--migrationPath'] = $model->path;
         }
         $params['upCode'] = $model->getUpCode();
         $params['downCode'] = $model->getDownCode();
         $output = $this->runMigrationAction('scaffold', $params);
         $output .= $this->runMigrationAction('up');
         $modules = ScaffoldForm::getModulesAsArray();
         $baseNs = @Yii::$app->getModule($modules[$model->path])->controllerNamespace ? Yii::$app->getModule($modules[$model->path])->controllerNamespace : Yii::$app->controllerNamespace;
         $ns = str_replace('\\controllers', '\\models', $baseNs);
         return $this->render('scaffoldForGii', ['title' => 'Scaffolding migration', 'output' => $output, 'tables' => $model->getTables(), 'ns' => $ns]);
     }
     return $this->render('scaffold', compact('model'));
 }
示例#2
0
</pre>

			Attributes must be separated by new line
			<br/>
			To create several tables, separated them with semicolon ";"
			<br/>
			ID and timestamps are auto created
		</div>

		<?php 
$form = ActiveForm::begin(['id' => 'create-migration']);
?>


		<?php 
echo $form->field($model, 'path')->dropDownList(ScaffoldForm::getModulesAsArray(), ['prompt' => '--- Application ---', 'autofocus' => true]);
?>

		<?php 
echo $form->field($model, 'name');
?>

		<?php 
echo $form->field($model, 'code')->textarea(['rows' => 10]);
?>

		<?php 
echo Html::submitButton('Create', ['class' => 'btn btn-primary']);
?>

		<?php