Creating depending Ojects (User -> Address) together

Hi guys

My problem: I have my create-form for a user. The user has an attached address which is saved in a different table. Now when i want to create a new user i’d like to have the input fields of the address as well. Of course with all the goodies (ajax validation, etc.).

I know i could first create an address and then choose it in the user-create form via dropdown, but this is not really what usability-guidelines tell :lol:

Is there any smart way i can use both existing models together in a create view without having to duplicate the code?

The actual goal would be to use a checkbox and let the cerator decide whether to use an existing address or create a new one.

My temporary solution: I used the wizard extension from the extension-directory and created two steps and two new models (CFormModel for displaying form data in the wizard) which then write their values into the existing models to save the data. stupid, but what can i do… :blink:

I already implemented the choosing between new or existing in the wizard.

Thanks for your help and enjoy your day,

pascal

I recommend you to read this wiki article. At least it helped me :).

http://www.yiiframework.com/wiki/19/how-to-use-a-single-form-to-collect-data-for-two-or-more-models/

Hi CTala

Thanks for your reply!

I saw this article. So you -have- to create a new view combining the two?

Yep, in just did it. I had the same problem as you had.