I have the following Scenario

Customer hasmany DomainName
CustomerAccount hasmany Domain Name
DomainName belongsto Customer
DomainName belongsto CustomerAccount

What I am trying to do is the following:

When creating a new customerAccount, a user first choses what customer
they would like. Then, a list of domain names owned by this customer
will be shown. This will be displayed as checkboxes. The enduser then
selects what domain names to associate with this new account, fill out
any other details and save.

When saving, all data should be saved in the customerAccount model,
and then using the new ID of this record, all selected domainNames
should be updated to refelect the customerAccount record they belong
to (DomainName.customer_account_id).

To find the domains I am doing this,

$this->set('domains', $this->CustomerAccount->DomainName->find(
                        'list',
                                array(
                                        'conditions' => array(
                                                'DomainName.customer_id' => $id)
                                )
                        )
                );

And to view these domains, I am doing the following:

echo $form->input(
                                        'DomainName.customer_account_id',
                                        array(
                                                'type' => 'select',
                                                'options' => $domains,
                                                'multiple' => 'checkbox',
                                                'class' => 'small-input',
                                                'div' => false)
                                );

But that doesn't work, as a new record is being created with the ID of
the newly added customer_account_id.

>From reading in the book this is what I understood the data form
should look like:
Each checkbox should be in the following format
DomainName.X.customer_account_id (x is 0 upwards)
Each X should have a hidden field representing the ID of the domain
name, DomainName.X.id

My problem is how to get my form look like that.

Thanks

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