有人实现过多表插入数据吗?
if(Yii::$app->request->isPost){
if(Yii::$app->request->post('Test') && $this->Test->load(Yii::$app->request->post()) && $this->Test->save($data)){
// var_dump($this->Dish->save());exit; 始终 是false
if(Yii::$app->request->post('Dish') && $this->Dish->save()){
return $this->render('index',[
'test' => $this->Test,
'dish' => $this->Dish,
]);
}else{
var_dump($dish); // 接受的是有值的
var_dump($this->Dish->getErrors()); // 接受的是空值
}
}else{
var_dump($this->Test->getErrors());
}
}else{
return $this->render('index',[
'test' => $this->Test,
'dish' => $this->Dish,
]);
}
这样是不行的吗?