Insert & Update id to another table

Hi,

I am trying to add record as new in update view, that i got, but now i am trying to add record & update its id to another table but its giving me error like below

Fatal error: Cannot unset string offsets in C:\Program Files\xampp\htdocs\yii\framework\web\helpers\CHtml.php on line 1905

My controller code is

[b][b]public function actionUpdate($id)

{


	$model=new ContactDetails;


	


	


	$model2=$this->loadModel($id);


	$model3=new CoApplicant;


	


	// Uncomment the following line if AJAX validation is needed


	// $this->performAjaxValidation($model);





	if(isset ($_POST['ContactDetails'], $_POST['CoApplicant']))


	


	{


		$model->attributeLabels=$_POST['ContactDetails'];


		


		 $model3->attributeLabels=$_POST['CoApplicant'];


		


		 $valid=$model->validate();


            $valid=$model3->validate() && $valid;


						


		if($valid)


		


		$model->save(false);


		unset($_POST['ContactDetails']);


		


        $model3->contact_deatails_id = $model->contact_details_id;


		


		$model3->save(false);


		unset($_POST['CoApplicant']);


		


		$this->redirect(Yii::app()->user->returnUrl);





			


			//$this->redirect(array('updateadd','id'=>$model2->contact_details_id));


	}





	$this->renderPartial('update',array(


		'model'=>$model2,


		'model3'=>$model3,


	));


}[/b][/b]

& my in my update form

[b]<?php echo $form->errorSummary($model,$model3); ?>

<div class="row buttons" align="right">

	&lt;?php echo CHtml::submitButton(&#036;model,&#036;model3-&gt;isNewRecord ? 'Create' : 'Save'); ?&gt;


&lt;/div&gt;


&lt;div class=&quot;row&quot;&gt;


            &lt;?php echo &#036;form-&gt;labelEx(&#036;model,'contact_details_id'); ?&gt;


            &lt;?php echo &#036;form-&gt;textField(&#036;model,'contact_details_id',array('size'=&gt;20,'maxlength'=&gt;20)); ?&gt;


            &lt;?php echo &#036;form-&gt;error(&#036;model,'contact_details_id'); ?&gt;


    &lt;/div&gt;[/b]

can any one help me , where i m wrong

plz plz help me

You mean attributes I think:





//$model->attributeLabels=$_POST['ContactDetails'];

$model->attributes=$_POST['ContactDetails'];


//$model3->attributeLabels=$_POST['CoApplicant'];

$model3->attributes=$_POST['CoApplicant'];






thank u for ur reply

I tryed that also but i able to insert but not able to update the id in another table

please help me

thanks again

Note: for your code to be more readable use the code directive (<> on the editor toolbar) - you can even edit your post to add that

For the error… check the documentation for CHtml::submitButton() - http://www.yiiframew…itButton-detail

NOTE: merged duplicate posts

HELLO TO ALL,

I AM TRYING TO FETCH DATA FOR THE TABLE ON CLICK OF AJAXSUBMIT BUTTON BUT ITS NOT WORKING. CAN ANYONE HELP ME …MY CODE IS GIVEN BELOW.




public function actionDynamicInsert() {

  

  $trn=new Trn;

  $caseno = $_POST['Trn']['case_no'];

  $case=$trn->attributes=$_POST['Trn']['case_no'];

  $data=  Trn::model()->findAll('case_no=:case_no',

  array(':case_no'=>(int)$case));

  $data=CHtml::listData($data,'case_no');

    if($data){  echo CHtml::encode(print_r("matched", true));}

   else{  echo CHtml::encode(print_r("Not matched", true));}

                                    



MY VIEW FILE IS


 <?php 

                                      

                                     

    echo CHtml::ajaxSubmitButton(

        'Submit request',

        array('Trn/DynamicInsert'),array(

            'update'=>'#req_res02',

        )

    );

             ?>

   <div id="req_res02">...</div>