50], [['bak', 'dept'], 'string', 'max' => 100], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'card_num' => '车牌号码', 'is_spec' => '特殊车辆', 'bak' => '说明', 'dept' => '所属单位', ]; } public function dptOptions($k=NULL) { $resultList = Yii::$app->db->createCommand("select distinct(dept) from {{%f_spc_car}}")->queryAll(); $options = []; if(is_array($resultList))foreach($resultList as $result) { $options[$result['dept']] = $result['dept']; } if($k)return $options[$k]; return $options; } }