I’m new to yii and got stuck
i’m using a wizard to create and update and i want to pass value from one model to other model, but in other model i’m not getting the value of first model.
thnx in advance
I’m new to yii and got stuck
i’m using a wizard to create and update and i want to pass value from one model to other model, but in other model i’m not getting the value of first model.
thnx in advance
Can U please provide more info or pass your code here?
Hi newbieayu.
you should follow the advice of dragan.zivkovic. but I think that you can create a relations between the two models to pass values.
This is a small Example:
public function relations()
{
//NOTE: you may need to adjust the relation name and the related
//class name for the relations automatically generated below.
return array(
'Ralationbetweenmodels' => array(self::BELONGS_TO, 'Modeltwo', 'idmodeltwo'),//This relations is create in your firts models
);
}
Regards.
Yii::import('application.models.MyModel');
$model = MyModel::model()->findByPk(1);
print_r($model);
Hi
You don’t give us enough details about your issue
If you want to get values of another model in another http request you should keep the stored model id
if you have a main id of the wizzard that integrate all of your required models you could use it like this
function actionStep1($wizzard_session_id) {
$model1 = new Model1();
//... set the attributes by the form...
//...
$model1->wizzard_session_id = $wizzard_session_id;
$model1->save();
}
function actionStep2($wizzard_session_id) {
$model2 = new Model2();
//... set the attributes by the form...
//...
$model2->wizzard_session_id = $wizzard_session_id;
$model1 = Model1::model()->findByattributes(array('wizzard_session_id'=>$wizzard_session_id));
//DO whatever you want with model1
$model2->save();
}
If you haven’t wizzard id integration please tell me to suggest you another way
Best regards
Apazidis Kostas