Wednesday, April 4, 2012

Saving Nested Models

This problem is beating me into a pulp, and if I could solve it I'd
really be making headway on my app.

Currently I have working the following type of relationship

Contact "belongsTo" Location
Location "hasMany" Contact

ie - contacts.location_id = locations.id

This works for all CRUD operations

Similarly

Location "belongsTo" BusinessTypes
BusinessTypes"hasMany" Location

ie - locations.business_types_id = business_types.id

What I need to do now, is to bring the above together to one Form,
which I'd normally do with joins, such that

contacts.location_id = locations.id AND locations.business_types_id =
business_types.id

In my view, the BusinessType model validation rules are being picked
up correctly as being displayed with "required", yet when I try to
save the form, the validation seems to forget itself, allowing the
Business Type to pass as an empty field, and of course, not get saved
to the DB.

How do I get Contacts->Location->BusinessType working!!!

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: