dear cakephp users,
i am in the process of extending a simple cakephp app which now
requires me to use multiple tables and data associations. now i'm
stuck at a problem and i looking for help!
basically i have one form from which i want to save/update to several
models. when the user adds or edits an artwork through the form, a new
entry should be created or an entry should be updated in the artwork
model. each artwork has a dealer, an artist and a location, which in
most cases already exist in respective table. so what i want is, when
i save the form in the artwork_controller, the app should check
whether the dealer, artist or location entered in the form already
exist and save this association using the respective_id to the artwork
model, or if not, create new one. right now, when i use saveAll, it
always creates new entries in the associated dealer, artist or
location tables.
these are my models:
class Artwork extends AppModel {
var $name = 'Artwork';
var $belongsTo = array(
'Artist', 'Dealer', 'Location'
);
}
class Artist extends AppModel {
var $name = 'Artist';
var $hasMany = array(
'Artwork' => array(
'className' => 'Artwork',
'dependent'=> false
)
);
}
class Dealer extends AppModel {
var $name = 'Dealer';
var $hasMany = array(
'Artwork' => array(
'className' => 'Artwork',
'dependent'=> false
)
);
}
class Location extends AppModel {
var $name = 'Location';
var $hasMany = array(
'Artwork' => array(
'className' => 'Artwork',
'dependent'=> false
)
);
}
i would highly appreciate if someone could help me understand how i
have to extend the artworks_controller add() and edit($id)
functions...
thank you for your attention!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---