_form.php 1.04 KB
Newer Older
Qiang Xue committed
1
<?php
Qiang Xue committed
2 3 4 5

use yii\helpers\Inflector;
use yii\helpers\StringHelper;

Qiang Xue committed
6
/**
Alexander Makarov committed
7
 * @var yii\web\View $this
Qiang Xue committed
8
 * @var yii\gii\generators\crud\Generator $generator
Qiang Xue committed
9 10
 */

Qiang Xue committed
11
/** @var \yii\db\ActiveRecord $model */
Qiang Xue committed
12
$model = new $generator->modelClass;
Qiang Xue committed
13 14
$safeAttributes = $model->safeAttributes();
if (empty($safeAttributes)) {
15
	$safeAttributes = $model->attributes();
Qiang Xue committed
16
}
Qiang Xue committed
17

Qiang Xue committed
18 19
echo "<?php\n";
?>
Qiang Xue committed
20

Qiang Xue committed
21 22
use yii\helpers\Html;
use yii\widgets\ActiveForm;
Qiang Xue committed
23

Qiang Xue committed
24
/**
Alexander Makarov committed
25
 * @var yii\web\View $this
Alexander Makarov committed
26
 * @var <?= ltrim($generator->modelClass, '\\') ?> $model
Qiang Xue committed
27 28
 * @var yii\widgets\ActiveForm $form
 */
Qiang Xue committed
29 30
?>

Alexander Makarov committed
31
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-form">
Qiang Xue committed
32

33
	<?= "<?php " ?>$form = ActiveForm::begin(); ?>
Qiang Xue committed
34 35

<?php foreach ($safeAttributes as $attribute) {
36
	echo "\t\t<?= " . $generator->generateActiveField($attribute) . " ?>\n\n";
Qiang Xue committed
37 38
} ?>
		<div class="form-group">
39
			<?= "<?= " ?>Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
Qiang Xue committed
40
		</div>
Qiang Xue committed
41

Luciano Baraglia committed
42
	<?= "<?php " ?>ActiveForm::end(); ?>
Qiang Xue committed
43

Qiang Xue committed
44
</div>