action.php 648 Bytes
Newer Older
Qiang Xue committed
1
<?php
Qiang Xue committed
2 3 4

use yii\helpers\Inflector;

Qiang Xue committed
5
/**
Qiang Xue committed
6 7
 * This is the template for generating an action view file.
 *
Alexander Makarov committed
8
 * @var yii\web\View $this
Qiang Xue committed
9
 * @var yii\gii\generators\form\Generator $generator
Qiang Xue committed
10
 */
11 12

echo "<?php\n";
Qiang Xue committed
13
?>
14

Alexander Makarov committed
15
public function action<?= Inflector::id2camel(trim(basename($generator->viewName), '_')) ?>()
Qiang Xue committed
16
{
17
	$model = new <?= $generator->modelClass ?><?= empty($generator->scenarioName) ? "" : "(['scenario' => '{$generator->scenarioName}'])" ?>;
Qiang Xue committed
18 19

	if ($model->load($_POST)) {
20
		if ($model->validate()) {
Qiang Xue committed
21 22 23 24
			// form inputs are valid, do something here
			return;
		}
	}
Alexander Makarov committed
25
	return $this->render('<?= $generator->viewName ?>', [
Qiang Xue committed
26
		'model' => $model,
Alexander Makarov committed
27
	]);
Qiang Xue committed
28
}