Save multiple models doesn't work

I want to save multiple models in database. So I do as follow :





/**

* $id : id of the participant

*/

public function actionAjoutInfo($id){

            try{

                $donnee =  array();

                $valeurFournie = array();


                $participant = Participant::model()->find('id_participant = ' . $id);

                

                if(!$participant){

                    $this->render('error', array('message' => 'Impossible de continuer'));

                }else{

                    $infos = InfoComplementAAjouter::model()->findAll('id_evenement = ' . $participant->id_evenement); 

                    foreach ($infos AS $i => $info){

                        $donnee[$i] = new DonneesComplementairesParticipant;

                        $vps = ValeursPossiblesInfoComplementaires::model()->findAll('id_InfoCompl = ' . $info->primaryKey);

                        foreach ($vps AS $j => $vp){

                            $valeurFournie[$i] = new ValeurFournie;

                            $this->performAjaxValidation($valeurFournie[$i], 'paricipant-formAdd');

                            

                        }

                        $this->performAjaxValidation($donnee[$i], 'participant-formAdd');


                    }

                    $i = 0;

                    if(isset($_POST['DonneesComplementairesParticipant']))

                    {

                        $this->printrequest();

                        // pour chaque données complémentaire, on effectue les affectations nécessaires et on sauvegarde.

                        foreach ($_POST['DonneesComplementairesParticipant'] AS $i => $P){

                            $donnee[$i]->setAttributes($P, FALSE);

                                

                                if($donnee[$i]->validate()){

                                    

                                    if($donnee[$i]->save())

                                    {

                                        if(isset($_POST['ValeurFournie'][$i])){

                                                foreach ($_POST['ValeurFournie'][$i]['valeurFournie'] AS $k => $V){

                                                    //Sélection de la valeur correspondant à la donnée; valeur fournie dans $_POST est un entier.

                                                    $critere2 = new CDbCriteria();

                                                    $critere2->select = 't.valeur';

                                                    $critere2->condition = 't.id_valeurPossible = ' . $V;




                                                    $valeur = ValeursPossiblesInfoComplementaires::model()->find($critere2);


                                                    $valeurFournie[$k]->valeurFournie = $valeur['valeur'];

                                                    $valeurFournie[$k]->id_donneesCompl = $donnee[$i]->id_donnees;

                                                    if($valeurFournie[$k]->validate()){

                                                        $valeurFournie[$k]->save();

                                                    }

                                            }

                                        }

                                    }

                                }else

                                   $this->printerror($donnee[$i]);//call to a method to print the error into a file

                                         


                        }

                        $this->redirect(array('viewSelf', 'id' => $id));

                    }

                    

                    

                    $this->render('addInfoParticipant', array('infoCompl' => $infos, 'donnees' => $donnee, 'valeurs' => $valeurFournie));

                }

            }  catch (Exception $e){

                

            }

                    

        }



The worst is that, the $_POST variable’s data don’t set any model attribute. Trying to debug, all the $donnee items are empty, although $_POST’s items aren’t.

Is there somebody to help me ?

hi

check value of ‘$i’ in ‘foreach ($infos AS $i => $info){… }’