Thanks Brother Marco.

--------------------------------------------------
From: "Marco" <[email protected]>
Sent: Monday, December 07, 2009 3:29 PM
To: "CakePHP" <[email protected]>
Subject: Re: Use of Associations in Add / Insert

> Something like that should work with model association hasOne between
> User and Customer models, check
> http://book.cakephp.org/view/84/Saving-Related-Model-Data-hasOne-hasMany-belongsTo
> for details
>
> view:
>
> echo $form->create('User', array('action'=>'add'));
> echo $form->input('FirstName');
> echo $form->input('LastName');
> echo $form->input('Customer.FirstName');
> echo $form->input('Customer.LastName');
> echo $form->end('Submit');
>
> controller:
>
> function add() {
>   if(!empty($this->data)) {
>      $this->User->saveAll($this->data);
>   }
> }
>
>
>
> On Dec 7, 2:55 am, Mohammad Raheel <[email protected]> wrote:
>> I have 3 different roles in my application. "Customers", "Customer
>> Support Agent", "Sales Rep".
>>
>> Common fields in all 3 are:
>>
>> FirstName
>> LastName
>> Email
>> username
>> password
>> role_id
>> etc.......
>>
>> Role Specific Fields are:
>>
>> Customers:
>> ==========
>>
>> 1. Social Security Number
>> 2. Date of Birth
>> 3. Credit Card Number
>> 4. ExpiryMonth , ExpiryYear
>> etc......
>>
>> Customer Support Agent & Sales Rep
>> ===================================
>> Nothing unique.
>>
>> I want to create a user management plugin to be reused in all projects
>> and want to keep common fields in users table. Question is how do i
>> generate a single view for customers add action so that it asks for
>> fields in both users and customers table and saves it appropriately in
>> both the tables. Rather can creating a user first and then selecting
>> that user in the customer add screen, i want simply a view to create
>> customer which inserts data in both the tables.
>>
>> If above design looks wrong, please advice any improvements and proper
>> solution to bake the MVCs.
>>
>> Thanks in advance
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group 
> at http://groups.google.com/group/cake-php?hl=en
> 

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to