On Sat, Jun 26, 2010 at 12:10 AM, guvilla <[email protected]> wrote:
> Scenary
> ==
> 4 tables: Users, Groups, Customers, Employee
>
> Groups: id, nome
> Users: id, username, password, group_id
> Customers: id, governamental_code, business_name, user_id
> Employee: id, name, user_id
>
> ==
> Question
> ==
> How to make (controllers and models) a single form with customer and
> user data together?
>


Untested, but I think this should work. Note the die(debug()) line,
which will show you how the data has been arranged.


function add()
{
        if (!empty($this->data))
        {
                die(debug($this->data));
        
                if ($this->Customer->User->save($this->data))
                {
                        $this->data['Customer']['user_id'] = 
$this->Customer->User->id;
                        
                        if ($this->Customer->save($this->data))
                        {
                                ...
                        }
                }
        }
        
        $this->set(
                'groups',
                $this->Customer->User->Group->find('list')
        );
}


echo $form->create('Customer', array('action' => 'add', ...));

echo $form->input('User.group_id', array('options' => $groups, 'label'
=> '...'));

echo $form->input('User.username');

echo $form->password('User.password');

etc.

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