action.php 725 Bytes
Newer Older
Qiang Xue committed
1 2
<?php
/**
Qiang Xue committed
3
 * This is the template for generating an action view file.
Qiang Xue committed
4
 */
5

6 7 8 9 10
use yii\helpers\Inflector;

/* @var $this yii\web\View */
/* @var $generator yii\gii\generators\form\Generator */

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

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

18 19 20 21 22 23 24 25 26 27
    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
28
}