You're probably right nurvzy, but if many contacts can have the same
phone number, then he could want a HABTM association.  If so there are
a few other issues with his setup

Table contacts_phone should be contacts_phones, as nurvzy said, but it
also requires an id field (all cake tables require an id field)

var $hasAndBelongsToMany = 'Phone';
var $hasAndBelongsToMany = 'Contact';

should both be

var $hasAndBelongsToMany = array('Phone');
var $hasAndBelongsToMany = array('Contact');

But then as nurvzy says your forms are all wrong as the phone ideally
needs to exist before you add your contact and are usually selected
from a multiple checkbox or select list.  So you may want to take his
advice and swap to a hasMany association and have the odd duplicate
phone number, but the management of those numbers will be sooo much
easier.

But if you want to stick with HABTM then you would need to either save
the contact or the phone first and then create the right data array
structure and run a save on the HABTM data, but then how do you offer
future contacts access to the already created phone numbers?

I would go with hasMany myself, but thought I'd provide the above as
you obviously have not got your head around the use of HABTM so will
come in useful at a future date.

HTH

Paul

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to