我已经阅读了很多信息,但我无法理解如何从checkBoxList获取actor id。我有桌子演员,连接,电影有很多很多。一切都差不多,在$_POST
点击保存表单后,有:
array (size=3)
'Film' =>
array (size=2)
'name' => string 'bvb' (length=3)
'about' => string 'fdgg' (length=4)
'Actors' =>
array (size=1)
'id' =>
array (size=1)
0 => string '2' (length=1)
'yt0' => string 'Create' (length=6)
所以我试图将我的$_POST['Actors']['id']
放到连接表中,但没有任何反应:
protected function afterSave(){
$actors=$this->ActorsArray;
parent::afterSave();
$postCat = new Connect();
$postCat->id_film = $this->id;
if (isset($_POST['Actors'])){
$postCat->id_actor = $_POST['Actors']}
$postCat->save();
}
这是来自电影控制员:
public function actionCreate()
{
$model=new Film;
$model1=new Actors();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Film']))
{
$model->attributes=$_POST['Film'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,'model1'=>$model1,
));
}