Skip to content

Instantly share code, notes, and snippets.

@evercode1
Created January 1, 2015 02:33
Show Gist options
  • Select an option

  • Save evercode1/2e76c6829de11952594a to your computer and use it in GitHub Desktop.

Select an option

Save evercode1/2e76c6829de11952594a to your computer and use it in GitHub Desktop.
profile view page chap 8
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use common\models\PermissionHelpers;
/**
* @var yii\web\View $this
* @var app\models\Profile $model
*/
$this->title = $model->user->username . "'s Profile";
$this->params['breadcrumbs'][] = ['label' => 'Profiles', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="profile-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?Php
//this is not necessary but in here as example
if (PermissionHelpers::userMustBeOwner('profile', $model->id)) {
echo Html::a('Update', ['update', 'id' => $model->id],
['class' => 'btn btn-primary']);
}
?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('app', 'Are you sure to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
//'id',
'user.username',
'first_name',
'last_name',
'birthdate',
'gender.gender_name',
'created_at',
'updated_at',
//'user_id',
],
]) ?>
</div>
@rngcontrol

Copy link
Copy Markdown

line 9 * @var frontend\models\Profile $model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment