1.index页面
在对应的控制器添加index方法
/**
* Article列表方法
* @var \app\admin\model\Video
*/
public function index()
{
//设置过滤方法
$this->request->filter(['strip_tags']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->where($where)
->with('goods')
->order($sort, $order)
->count();
$list = $this->model
->where($where)
->with('goods')
->order($sort, $order)
->limit($offset, $limit)
->select();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
对应的model文件
public function goods()
{
return parent::hasOne('Goods','id','goods_id')->field('id,title');
}
对应的js文件
{field: 'goods.title', title: __('Goods_title')}
2.编辑,添加页面,主要加上 data-source="goods/index" data-field="title"
对应的html页面
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Goods_id')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-goods_id" data-rule="required" data-source="goods/index" data-field="title" class="form-control selectpage form-control" name="row[goods_id]" type="text" value="{$row.goods_id}">
<p class="t_notic">填写产品ID</p>
</div>
</div>
网友评论