CFormModel -> CActiveRecord

Hi,

what could be the best technique to transform the data from the one model into the second one to persist them.

Any hints?

Thanks

Probably, the primer question is: why do you need two same-looking models? I always follow the rule: if your code duplicates then something's wrong in the app design. Probably, you need to think one level higher. What led to this need?

Anyway,

foreach ($fm as $name => $value)


    $ar->$name = $value;

hi

thanks for the foreach :wink: i have two models because i use the form validation, activeLabels and so on. If i dont use that all, then i wouldnt need yii :wink: So i would say thats the concept. Now i need an elegant way to transform objects in eachother.

Simple foreach is not enough because i might have dates or differnet types which need to be converted, too.

Thanks for your reply…

Boris

CFormModel and CActiveRecord are both inherited from CModel and both support form validation and labels. I would personally avoid such a complex solutions.

This is actually right what you say. I try it this way, lets see…

Thanks

I have changed my code, it worked until i had a property called passwordRetype.

This is not persisted, so i though i can put in my model as a class var and this will be populated while setting the attributes by the $_POST[xyz]

But this is not the case. although the POST var exists, it is not set into the model, does someone know how to implement non persistent properties within the model?

Thanks

Please check this post: http://www.yiiframew…11.msg1704.html

Thanks for your quick reply. But i cant see the relation to my problem :frowning: I already use the scenario conecpt, and think thats a nice idea.

But i dont know how to solve the additional non persistent attribute problem with that thread.