view.php 1.57 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
$urlParams = $generator->generateUrlParams();
Qiang Xue committed
12

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

Qiang Xue committed
16
use yii\helpers\Html;
Qiang Xue committed
17
use yii\widgets\DetailView;
Qiang Xue committed
18

Qiang Xue committed
19
/**
Alexander Makarov committed
20
 * @var yii\web\View $this
Alexander Makarov committed
21
 * @var <?= ltrim($generator->modelClass, '\\') ?> $model
Qiang Xue committed
22
 */
Qiang Xue committed
23

Alexander Makarov committed
24 25
$this->title = $model-><?= $generator->getNameAttribute() ?>;
$this->params['breadcrumbs'][] = ['label' => '<?= Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass))) ?>', 'url' => ['index']];
Qiang Xue committed
26
$this->params['breadcrumbs'][] = $this->title;
Qiang Xue committed
27
?>
Alexander Makarov committed
28
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass)) ?>-view">
Qiang Xue committed
29

30
	<h1><?= "<?= " ?>Html::encode($this->title) ?></h1>
Qiang Xue committed
31

Qiang Xue committed
32
	<p>
33 34
		<?= "<?= " ?>Html::a('Update', ['update', <?= $urlParams ?>], ['class' => 'btn btn-primary']) ?>
		<?= "<?php " ?>echo Html::a('Delete', ['delete', <?= $urlParams ?>], [
Qiang Xue committed
35 36 37
			'class' => 'btn btn-danger',
			'data-confirm' => Yii::t('app', 'Are you sure to delete this item?'),
			'data-method' => 'post',
Alexander Makarov committed
38
		]); ?>
Qiang Xue committed
39
	</p>
Qiang Xue committed
40

41
	<?= "<?php " ?>echo DetailView::widget([
Qiang Xue committed
42
		'model' => $model,
Alexander Makarov committed
43
		'attributes' => [
Qiang Xue committed
44
<?php
45 46 47 48 49 50 51 52 53
if (($tableSchema = $generator->getTableSchema()) === false) {
	foreach ($generator->getColumnNames() as $name) {
		echo "\t\t\t'" . $name . "',\n";
	}
} else {
	foreach ($generator->getTableSchema()->columns as $column) {
		$format = $generator->generateColumnFormat($column);
		echo "\t\t\t'" . $column->name . ($format === 'text' ? "" : ":" . $format) . "',\n";
	}
Qiang Xue committed
54 55
}
?>
Alexander Makarov committed
56 57
		],
	]); ?>
Qiang Xue committed
58

Qiang Xue committed
59
</div>