action.php 720 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 20 21 22 23 24 25 26 27 28
    if ($model->load(Yii::$app->request->post())) {
        if ($model->validate()) {
            // form inputs are valid, do something here
            return;
        }
    }

    return $this->render('<?= $generator->viewName ?>', [
        'model' => $model,
    ]);
Qiang Xue committed
29
}