Qiang Xue
12 years ago
6 changed files with 99 additions and 24 deletions
@ -1,8 +1,26 @@
|
||||
<?php |
||||
|
||||
use yii\helpers\Inflector; |
||||
|
||||
/** |
||||
* Created by JetBrains PhpStorm. |
||||
* User: qiang |
||||
* Date: 8/17/13 |
||||
* Time: 3:48 PM |
||||
* To change this template use File | Settings | File Templates. |
||||
* This is the template for generating an action view file. |
||||
* |
||||
* @var yii\base\View $this |
||||
* @var yii\gii\generators\form\Generator $generator |
||||
*/ |
||||
?> |
||||
<?php echo "<?php\n"; ?> |
||||
public function action<?php echo Inflector::id2camel(trim(basename($generator->viewName), '_')); ?>()
|
||||
{ |
||||
$model = new <?php echo $generator->modelClass; ?><?php echo empty($generator->scenarioName) ? '' : "(array('scenario' => '{$generator->scenarioName}'))"; ?>;
|
||||
|
||||
if ($model->load($_POST)) { |
||||
if($model->validate()) { |
||||
// form inputs are valid, do something here |
||||
return; |
||||
} |
||||
} |
||||
return $this->render('<?php echo $generator->viewName; ?>', array(
|
||||
'model' => $model, |
||||
)); |
||||
} |
||||
|
@ -1,8 +1,34 @@
|
||||
<?php |
||||
/** |
||||
* Created by JetBrains PhpStorm. |
||||
* User: qiang |
||||
* Date: 8/17/13 |
||||
* Time: 3:47 PM |
||||
* To change this template use File | Settings | File Templates. |
||||
* This is the template for generating an action view file. |
||||
* |
||||
* @var yii\base\View $this |
||||
* @var yii\gii\generators\form\Generator $generator |
||||
*/ |
||||
?> |
||||
<?php echo "<?php\n"; ?> |
||||
|
||||
use yii\helpers\Html; |
||||
use yii\widgets\ActiveForm; |
||||
|
||||
/** |
||||
* @var yii\base\View $this |
||||
* @var <?php echo $generator->modelClass; ?> $model
|
||||
* @var ActiveForm $form |
||||
*/ |
||||
<?php echo "?>"; ?> |
||||
|
||||
<div class="<?php echo str_replace('/', '-', trim($generator->viewName, '_')); ?>">
|
||||
|
||||
<?php echo '<?php'; ?> $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?php foreach ($generator->getModelAttributes() as $attribute): ?> |
||||
<?php echo '<?php'; ?> echo $form->field($model, '<?php echo $attribute; ?>'); ?>
|
||||
<?php endforeach; ?> |
||||
|
||||
<div class="form-group"> |
||||
<?php echo '<?php'; ?> echo Html::submitButton('Login', array('class' => 'btn btn-primary')); ?>
|
||||
</div> |
||||
<?php echo '<?php'; ?> ActiveForm::end(); ?>
|
||||
|
||||
</div><!-- <?php echo str_replace('/', '-', trim($generator->viewName, '-')); ?> -->
|
||||
|
Loading…
Reference in new issue