示例#1
0
文件: Article.php 项目: tolik505/bl
 /**
  * Get attribute columns for index and view page
  *
  * @param $page
  *
  * @return array
  */
 public function getColumns($page)
 {
     switch ($page) {
         case 'index':
             return [['class' => 'yii\\grid\\SerialColumn'], 'label', 'alias', ['attribute' => 'category_id', 'filter' => ArticleCategory::getItems(), 'value' => function (self $data) {
                 return isset($data->category->label) ? $data->category->label : '';
             }], 'date', 'tags', 'views', 'published:boolean', 'position', ['class' => 'yii\\grid\\ActionColumn']];
             break;
         case 'view':
             return ['id', 'label', 'alias', ['attribute' => 'category_id', 'filter' => ArticleCategory::getItems(), 'value' => isset($this->category->label) ? $this->category->label : ''], ['attribute' => 'announce', 'format' => 'html'], ['attribute' => 'content', 'format' => 'html'], 'date', 'tags', 'views', 'published:boolean', 'position'];
             break;
     }
     return [];
 }