注意點:
<input type="text"name="{$cate.id}" style="width:50px;text-align:center;"value="{$cate.sort}">
在前端代碼中,把排序的name變成相應的欄目id,這樣就方便後續修改;
控制器層中處理代碼:
public function lst()
{
$cate =new CateModel();
if(request()->isPost()){
$sorts = input('post.');
foreach ($sorts as $k => $v) {
$cate->update(['id'=>$k,'sort'=>$v]);
}
$this->success('更新排序成功!',url('lst'));
return;
}
$cateres= $cate->catetree();
$this->assign('cateres',$cateres);
returnview();
}