Hi again Mark :o)

HABTM in cake is just a convenience wrapper for

Contact hasMany ContactPhone
Phone hasMany ContactPhone
ContactPhone
  belongsTo Contact
  belongsTo Phone

As such the HABTM association when using saveAll() is only expecting
the following data

ContactPhone.contact_id
ContactPhone.phone_id

It's never going to create the record

Phone.id
Phone.phone

Then pass Phone.id back into

ContactPhone.contact_id
ContactPhone.phone_id

And save it.

And even if it did, how are you going to check if the phone number
entered already exists or not in your phone model and select an
existing ID rather than creating a duplicate phone number?  If this is
a HABTM association, why are you only including one phone field in the
form?

I would seriously consider dropping the idea of using HABTM between
user and phone, but if you want to persist there are a lot of advanced
things you need to do within this save process to ensure data
integrity with beforeValidate and beforeSave within your various
models to ensure your data integrity and to reformat your data arrays
to then save your Contact record and create your join records to
Phone.

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 [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