view.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Author: lf
  4. * Blog: https://blog.feehi.com
  5. * Email: job@feehi.com
  6. * Created at: 2018-02-24 21:04
  7. */
  8. use common\libs\Constants;
  9. use yii\widgets\DetailView;
  10. /**
  11. * @var $model backend\models\form\AdForm
  12. */
  13. ?>
  14. <?= DetailView::widget([
  15. 'model' => $model,
  16. 'attributes' => [
  17. 'name',
  18. [
  19. 'attribute' => 'input_type',
  20. 'value' => function($model){
  21. return Constants::getAdTypeItems($model->input_type);
  22. }
  23. ],
  24. 'tips',
  25. [
  26. 'attribute' => 'ad',
  27. 'format' => 'raw',
  28. 'value' => function($model){
  29. switch ($model->input_type){
  30. case Constants::AD_IMG:
  31. return "<img style='max-width: 200px;max-height: 150px' src='{$model->ad}'>";
  32. case Constants::AD_VIDEO:
  33. return "<video style='max-width: 200px;max-height: 150px' src='{$model->ad}' controls='controls'></video>";
  34. case Constants::AD_TEXT:
  35. return $model->ad;
  36. }
  37. }
  38. ],
  39. 'link',
  40. 'desc',
  41. [
  42. 'attribute' => 'autoload',
  43. 'value' => function($model){
  44. return Constants::getYesNoItems($model->autoload);
  45. }
  46. ],
  47. 'sort',
  48. [
  49. 'attribute' => 'target',
  50. 'value' => function($model){
  51. return Constants::getTargetOpenMethod($model->target);
  52. }
  53. ],
  54. 'created_at:datetime',
  55. 'updated_at:datetime'
  56. ],
  57. ]);