view.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2018-02-24 20:48
  7. */
  8. use common\libs\Constants;
  9. use yii\widgets\DetailView;
  10. /**
  11. * @var $model backend\models\form\BannerForm
  12. */
  13. ?>
  14. <?= DetailView::widget([
  15. 'model' => $model,
  16. 'attributes' => [
  17. 'name',
  18. 'tips',
  19. [
  20. 'attribute' => 'img',
  21. 'format' => 'raw',
  22. 'value' => function($model){
  23. if( empty($model->img) ) return '';
  24. return "<img style='max-width:200px;max-height:200px' src='" . $model->img . "'>";
  25. }
  26. ],
  27. [
  28. 'attribute' => 'target',
  29. 'value' => function($model){
  30. return Constants::getTargetOpenMethod($model->target);
  31. }
  32. ],
  33. 'link',
  34. 'sort',
  35. [
  36. 'attribute' => 'status',
  37. 'value' => function($model){
  38. return Constants::getStatusItems($model->status);
  39. }
  40. ],
  41. 'desc',
  42. ],
  43. ]);