Can anybody help me resolve my issue? I’m able to do create new records but I can’t modify or update my existing records.
Here is my source code:
public function actionCreate() {
$model = new Branchmaster;
$user = new Usermaster;
if(isset($_POST['Branchmaster'], $_POST['Usermaster'])) {
$model->attributes=$_POST['Branchmaster'];
$user->attributes=$_POST['Usermaster'];
$valid=$model->validate();
$valid=$user->validate() && $valid;
if($valid){
$model->save();
$chnuser->save();
$this->redirect(array('view','id'=>$model->Id));
}
}
$this->render('create',array(
'model'=>$model,
'user'=>$user,
));
}
public function actionUpdate($id) {
$model=$this->loadModel($id);
$user = Usermaster::model()->findByAttributes(array('branch_id'=>$model->Id));
if(isset($_POST['Branchmaster'], $_POST['Usermaster'])) {
$model->attributes=$_POST['Branchmaster'];
$user->attributes=$_POST['Usermaster'];
$valid=$model->validate();
$valid=$user->validate() && $valid;
if($valid){
$model->save();
$user->save();
$this->redirect(array('view','id'=>$model->Id));
}
}
$this->render('update',array(
'model'=>$model,
'user'=>$user,
));
}
[twitter]rohisuthar[/twitter]