2017-09-14 140 views

回答

1

嗨,你必须使用关系字段类型,改变你的columns.yaml和,而不是使用user_id是这样的:

user: 
label: Username 
type: relation 
select: login 

记住user是你们的关系在belongsTo定义的名称阵列

您应该在您的模型中定义了正确的关系

<?php 

class YourModel extends Model 
{ 
    $belongsTo = ['user'=>'Backend\Models\User']; 
} 

对于您YourModel.php更多信息http://octobercms.com/docs/backend/lists#column-relation

+0

谢谢OsDev的回答。它适用于我的情况。 – H2O3

0

,添加这种关系

public $hasOne = [ 
     'user' => ['Backend\Models\User', 'key' => 'id', 'otherKey' => 'user_id'] 
      ]; 
在columns.yaml

,添加此

user: 
 
     label: 'Username' 
 
     type: text 
 
     select: username //field from users table 
 
     relation: user //relation name is the key defined in model "hasone" relation

相关问题