本文整理汇总了PHP中yii\widgets\DetailView::className方法的典型用法代码示例。如果您正苦于以下问题:PHP DetailView::className方法的具体用法?PHP DetailView::className怎么用?PHP DetailView::className使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\widgets\DetailView
的用法示例。
在下文中一共展示了DetailView::className方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?php
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\widgets\DetailView;
use asdfstudio\admin\components\AdminFormatter;
/**
* @var yii\web\View $this
* @var yii\db\ActiveRecord $model
* @var asdfstudio\admin\base\Entity $entity
*/
$this->title = $entity->labels()[0];
$this->params['breadcrumbs'][] = ['label' => $entity->labels()[1], 'url' => ['manage/index', 'entity' => $entity->id]];
$this->params['breadcrumbs'][] = Yii::t('admin', 'View');
$detail = $entity->detail();
$class = ArrayHelper::remove($detail, 'class', DetailView::className());
$defaultDetail = ['model' => $model, 'formatter' => ['class' => AdminFormatter::className()]];
$detail = ArrayHelper::merge($defaultDetail, $detail);
$primaryKey = $entity->primaryKey();
?>
<div class="model-view">
<p>
<?php
echo Html::a(Yii::t('admin', 'Edit'), ['update', 'entity' => $entity->id, 'id' => $model->{$primaryKey}], ['class' => 'btn btn-primary']);
?>
<?php
echo Html::a(Yii::t('admin', 'Delete'), ['delete', 'entity' => $entity->id, 'id' => $model->{$primaryKey}], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('admin', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
</p>
<div class="row">
示例2: detail
/**
* Detail view of model
* Default detail view class is `asdfstudio\admin\details\Detail`
* For configuration syntax see [[asdfstudio\admin\details\Detail]]
*
* ```php
* return [
* 'class' => vendorname\blog\details\PostDetail::className(),
* ];
* ```
*
* @return array
*/
public function detail()
{
return ['class' => DetailView::className()];
}