view.php 1.58 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
			'class' => 'btn btn-danger',
36 37 38 39
			'data' => [
				'confirm' => Yii::t('app', 'Are you sure to delete this item?'),
				'method' => 'post',
			],
Alexander Makarov committed
40
		]); ?>
Qiang Xue committed
41
	</p>
Qiang Xue committed
42

43
	<?= "<?php " ?>echo DetailView::widget([
Qiang Xue committed
44
		'model' => $model,
Alexander Makarov committed
45
		'attributes' => [
Qiang Xue committed
46
<?php
47 48 49 50 51 52 53 54 55
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
56 57
}
?>
Alexander Makarov committed
58 59
		],
	]); ?>
Qiang Xue committed
60

Qiang Xue committed
61
</div>