Hi everybody and thanks for reading .
I have a Create form where i create meeting’s. Each meeting has some participants that are saved on bridge table.
This is the code i use on the Meetings controler to insert a new meeting and the participants to the meeting ;
public function actionCreate()
{
$model=new Meeting;
if(isset($_POST['Meeting']))
{
$model->attributes=$_POST['Meeting'];
if($model->save())
//upload the partecipants
$partecipants = $_POST['Meeting']['partecipants'];
if(!empty($partecipants))
{
foreach($partecipants as $partecipant){
$bridge=new BridgeWg();
$bridge->id_wg=$model->id_wg;
$bridge->id_user_registry=$partecipant;
$bridge->save(false);
}
}
$this->redirect(array('view','id'=>$model->id_wg));
}
$this->render('create',array(
'model'=>$model,
));
}
in the view i have the following code
<?php echo $form->checkBoxListInlineRow($model, 'partecipants', CHtml::listData(UserRegistry::model()->findAll(), 'id_user_registry', 'firstname')); ?>
"partecipants" is a filed not present in the db so i defined it as public $participants in the model Meetings
Anybody has an idea how i can load the participants on the update page and have all the boxes checked of the participants i inserted during the creation of the Meeting.
Let me know if anybody has an idea or a link i could reffer to .
Thanks in advance