view.php 1.5 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 22:03
  7. */
  8. use common\libs\Constants;
  9. use yii\widgets\DetailView;
  10. /** @var $model backend\models\Menu */
  11. ?>
  12. <?=DetailView::widget([
  13. 'model' => $model,
  14. 'attributes' => [
  15. 'id',
  16. 'parent_id',
  17. [
  18. 'label' => Yii::t('app', 'Parent Menu Name'),
  19. 'attribute' => 'parent_id',
  20. 'value' => function($model){
  21. return $model->parent === null ? '' : $model->parent->name;
  22. }
  23. ],
  24. 'name',
  25. 'url',
  26. [
  27. 'attribute' => 'icon',
  28. 'format' => 'raw',
  29. 'value' => function($model){
  30. if( empty($model->icon) ) return '';
  31. return "<i class='" . $model->icon . "'></i>";
  32. }
  33. ],
  34. 'sort',
  35. [
  36. 'attribute' => 'is_absolute_url',
  37. 'value' => function($model){
  38. return Constants::getYesNoItems($model->is_absolute_url);
  39. }
  40. ],
  41. [
  42. 'attribute' => 'target',
  43. 'value' => function($model){
  44. return Constants::getTargetOpenMethod($model->target);
  45. }
  46. ],
  47. [
  48. 'attribute' => 'is_display',
  49. 'value' => function($model){
  50. return Constants::getYesNoItems($model->is_display);
  51. }
  52. ],
  53. 'created_at:datetime',
  54. 'updated_at:datetime',
  55. ],
  56. ])
  57. ?>