public function _before_index() {
$model = M("Group");
$list = $model->where('status=1')->getField('id,title');
$this->assign('groupList', $list);
}
// 获取配置类型
public function _before_add() {
$model = M("Group");
$list = $model->where('status=1')->select();
$this->assign('grouplist', $list);
$Node = D("Node");
$nodelist = $Node->where('level < 3')->order("pid")->select();
$as = new \Org\Util\ArraySort($nodelist);
$nlist = $as->listArray();
$this->assign('list', $nlist);
}
public function _before_edit() {
$model = M("Group");
$list = $model->where('status=1')->select();
$this->assign('grouplist', $list);
$Node = D("Node");
$nodelist = $Node->where('level<3')->order("pid")->select();
$as = new \Org\Util\ArraySort($nodelist);
$nlist = $as->listArray();
$this->assign('list', $nlist);
}
我的代码习惯如下 // 添加账目
public function add(){
if(IS_POST){
// print_r(I('post.'));die();
// Array ( [fee] => 299 [pay_date] => 2018-06-04 [type] => 4 [info] => ddddd )
} else {
$type_list = M('Paytype')->select();
$this->assign('typelist',$type_list);
$this->display();
}
}
// 编辑账目
public function edit()
{
if(IS_POST){
print_r(I('post.'));die();
} else {
$this->display();
}
}
我怎么觉得没必要使用_before_insert 这类的前回调啊 最佳答案
