index.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. use yii\grid\GridView;
  3. use yii\helpers\ArrayHelper;
  4. use yii\helpers\Html;
  5. use yii\helpers\Url;
  6. /**
  7. * @var $this \yii\web\View
  8. * @var $dataProvider \yii\data\ActiveDataProvider
  9. */
  10. $this->title = '区块';
  11. $this->params['breadcrumbs'][] = $this->title;
  12. ?>
  13. <?php $this->beginBlock('content-header'); ?>
  14. <h1>
  15. <?= $this->title?> <a class="btn btn-success "
  16. href="<?= Url::to(['create']) ?>">新区块
  17. </a>
  18. </h1>
  19. <?php $this->endBlock(); ?>
  20. <div class="box box-success">
  21. <div class="box-body">
  22. <?= GridView::widget([
  23. 'dataProvider' => $dataProvider,
  24. "columns"=>[
  25. 'block_id',
  26. [
  27. 'attribute' => 'title',
  28. "format"=>"html",
  29. 'value'=>function($model, $key, $index, $column)
  30. {
  31. $params = is_array($key) ? $key : ['id' => (string) $key];
  32. $params[0] = "update";
  33. $value = ArrayHelper::getValue($model, $column->attribute);
  34. return Html::a($value,$params);
  35. }
  36. ],
  37. 'slug',
  38. 'type',
  39. [
  40. 'class' => 'yii\grid\ActionColumn',
  41. 'template'=>"{update} {delete}"
  42. ]
  43. ]
  44. ]);
  45. ?>
  46. </div>
  47. </div>