Hi all, Well I have been stuck up for some time with this problem.
Well I have Registration page in my application. The Registration process can be done in ways. 1. When a new Customer comes directly for registration. 2. When a Lead becomes a Customer. My Registration Object has the following relation. Registration - hasMany - EducationalDetails - hasMany - ProfessionalDetails - hasMany - EligibilityTests - hasMany - CandidateStudyAbroad. When a new Customer comes for Registration the data would be empty and while saving REGISTRATION and all its corresponding models are getting stored. So far no issues. But when an existing Lead is being Registered, I am sending the Lead Id through URL, retrieving it from database and populating the Registration form using $this->data(). The form is rendering perfect with all the values populated. But when I am trying to save the Form, the values for the Registration object except created ans modified are not being saved. The values for the corresponding related object are all being saved well. When I checked the Query that is being run I found out that in the second condition only the created and modified values are being Inserted for REGISTRATION object. My Controller Function : function studyabroadregistration($id = null){ if (array_key_exists('cancel', $this->params['form'])){ $this->Session->setFlash('Action Cancelled.',true); $this->redirect(array('controller'=>'registrations','action'=>'index')); }else if(array_key_exists('cancelfromlead', $this->params['form'])){ $this->Session->setFlash('Action Cancelled.',true); $this->redirect(array('controller'=>'leads','action'=>'index')); }else if(array_key_exists('save', $this->params['form'])){ if (!empty($this->data)) { $this->data['Registration']['display_name']=$this->data['Registration']['first_name'].' '.$this->data['Registration']['last_name']; $this->data['Registration']['file_number']='IA2009'; $this->data['Registration']['service_intrested']='Study Abroad'; $this->data['Registration']['registration_date']=$this->DateHelper->getNextDate(); $this->data['Registration']['registration_status']='NEW'; for($i=0;$i<sizeof($this->data['ProfessionalDetail']);$i++){ if($this->data['ProfessionalDetail'][$i]['start_date'] != null) $this->data['ProfessionalDetail'][$i]['start_date']=date("Y-m-d H:i:s",strtotime($this->data['ProfessionalDetail'][$i]['start_date'])); $this->log($this->data['ProfessionalDetail'][$i]['start_date']); if($this->data['ProfessionalDetail'][$i]['end_date'] != null) $this->data['ProfessionalDetail'][$i]['end_date']=date("Y-m-d H:i:s",strtotime($this->data['ProfessionalDetail'][$i]['end_date'])); $this->log($this->data['ProfessionalDetail'][$i]['end_date']); } debug($this->data); if ($this->Registration->saveAll($this->data)) { //$this->Registration->save() if($this->data['Registration']['lead_id'] !=null){ $leadId=$this->data['Registration']['lead_id']; $this->data = $this->Lead->read(null, $leadId); $this->data['Lead']['registration_id']=$this->Registration->getLastInsertId(); $this->data['Lead']['status']='Completed'; $this->Lead->save($this->data['Lead']); } $this->Session->setFlash(__('The Registration has ergqwerg been saved', true)); //$this->redirect(array('controller'=>'registrations','action'=>'registrationlist')); }else{ $this->Session->setFlash(__('The Registration could not be saved. Please, try again.', true)); } } }else{ if(isset ($id) && empty($this->data)){ $this->set('from', 'lead'); $lead = $this->Lead->read(null, $id); $this->data['Registration']['first_name'] =$lead['Lead']['first_name']; $this->data['Registration']['middle_name'] =$lead['Lead']['middle_name']; $this->data['Registration']['last_name'] =$lead['Lead']['last_name']; $this->data['Registration']['address_line1'] =$lead['Contact']['address_line1']; $this->data['Registration']['address_line2'] =$lead['Contact']['address_line2']; $this->data['Registration']['address_line3'] =$lead['Contact']['address_line3']; $this->data['Registration']['city'] =$lead['Contact']['city']; $this->data['Registration']['state'] =$lead['Contact']['state']; $this->data['Registration']['country_name'] =$lead['Contact']['country_name']; $this->data['Registration']['postal_code'] =$lead['Contact']['postal_code']; $this->data['Registration']['primary_email'] =$lead['Contact']['primary_email']; $this->data['Registration']['secondary_email'] =$lead['Contact']['secondary_email']; $this->data['Registration']['mobile_number'] =$lead['Contact']['mobile_number']; $this->data['Registration']['home_phone'] =$lead['Contact']['home_phone']; $this->data['Registration']['office_phone'] =$lead['Contact']['office_phone']; $this->set('leadID',$lead['Lead']['id']); $this->set($this->data); } $this->Country->recursive = -1; $this->set('countryList', $this->Country->myGenerateList(null, null, null,'{n}.Country.id', '{n}.Country.name')); } } My view is dynamic view : I am just pasting the form elements. <?php echo $form->create('Registration', array('action' => 'studyabroadregistration','url'=>array('controller' => 'registrations')));?> <table class="tabform" style="border-top:none" cellspacing="1" cellpadding="0" border="0" width="100%" > <tr style="height:25px"> <th align="left" colspan="8" ><h4>Personal Information</h4></th> </tr> <tr> <td><div class="formLabel"> First Name <span class="required">*</span></div></td> <td><?php echo $form->input('first_name', array('label' => '','className'=>'formInput')); echo $form->hidden('id'); ?></td> <td><div class="formLabel"> Middle Name</div></td> <td><?php echo $form->input('middle_name', array('label' => '','className'=>'formInput'));?></td> <td><div class="formLabel"> Last Name <span class="required">*</span></div></td> <td><?php echo $form->input('last_name', array('label' => '','className'=>'formInput'));?></td> </tr> <tr> <td><div class="formLabel"> Gender</div></td> <td> <input name="data[Registration][gender]" id="Male" value="Male" type="radio" checked >Male <input name="data[Registration][gender]" id="Female" value="Female" type="radio" >Female </td> <td><div class="formLabel"> Marital Status </div></td> <td><?php echo $form->input('marital_status', array('label' => '','type'=>'select','empty'=>'Select','options'=>array( 'married' =>'Married', 'single' => 'Single', 'divorced' => 'Divorced'),'className'=>'formInput'));?></td> </tr> <tr> <td><div class="formLabel"> Date Of Birth <span class="required">*</span></div></td> <td colspan="2"><?php echo $form->input('dob', array('label' => '','className'=>'formInput','timeFormat'=>''));?></td> </tr> </table> <table class="tabform" cellspacing="1" cellpadding="0" border="0" width="100%" > <tr style="height:25px"> <th align="left" colspan="9" ><h4>Educational Summary</h4></th> </tr> <tr> <td> <table border="1" cellspacing="1" width="100%" style="border:1px solid #c0c0c0;" > <th class="eligibility_th">Course Name</th> <th class="eligibility_th">Stream</th> <th class="eligibility_th">Year Of Passing</th> <th class="eligibility_th">University</th> <th class="eligibility_th"></th> <tr> <td style="width:25%;text-align:left;"><?php echo $form->input('EducationDetail.0.course_name',array('label'=>'','size'=>'30')); ?></td> <td style="width:25%;text-align:left;"><?php echo $form->input('EducationDetail.0.stream',array('label'=>'','size'=>'30')); ?></td> <td style="width:25%;text-align:left;"><?php echo $form->input('EducationDetail.0.year_of_passing',array('label'=>'')); ?></td> <td style="width:22%;text-align:left;"><?php echo $form->input('EducationDetail.0.university_name',array('label'=>'','size'=>'30')); ?></td> <td style="width:3%;text-align:center;"><a href="javascript:addEducationalDetails();"><img src="../img/plus_inline1.gif" width="10" height="10"></a></td> </tr> <tr> <td colspan="5" style="padding:0px"><div id="parentDiv" style="width:100%" > </div></td> </tr> </table> </td> </tr> </table> The javascript function here adds rows of educational details row by row with perfect numbering. Well this part has been troubling me for some part. What I have done wrong ? . Please help. -- Sijo Jose Chakramakkil --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---