Update related model data
Hi, Before I start: creating a user with an email gives no problem, but updating a user, gives a validation error: 'email left blank'. I have this array and I want to save the updated data Array ( [User] => Array ( [firstname] => data[User][firstname] [lastname] => data[User][lastname] [address] => data[User][address] [zip_code] => dat [city] => data[User][city] [country_id] => 149 [gender] => 2 [age] => 55 ) [Email] => Array ( [0] => Array ( [email] => vin...@zonnet.nl ) ) ) I do the following things to update it: $this->User->read(null, $this->authUser['User']['id']); $this->User->Email->save($this->data) && $this->User->save($this- >data); I couldn't even get saveAll method to work well. The user saves well, but the email gives a validation error, that it is empty (cannot be left blank). The relationship is as follows: user has many emails. What am I doing wrong? Cake thinks, the email is left blank, but in fact it isn't. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Update related model data
hi, did you check this: http://book.cakephp.org/view/75/Saving-Your-Data --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Update related model data
Just wondering where to start when saving related model data. Links or tutorials? Basically I want to remove the functions for updating THINGS and OTHERS from the USERS_CONTROLLER and use the native THINGS_CONTROLLER and OTHERS_CONTROLLER I have 3 controllers: users_controller : right now "USERS/EDIT/1" is a standard form to edit/update all the info. THINGS and OTHERS are related data updated using select boxes. things_controller: I have no code in the controller others_controller: I have no code in the controller The tables: USERS THINGS OTHERS USERS_THINGS USERS_OTHERS USERS -> hasAndBelongsToMany THINGS USERS -> hasAndBelongsToMany OTHERS THINGS -> hasAndBelongsToMany USERS OTHERS -> hasAndBelongsToMany USERS Dave --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: update related model data
Did you try setting $this->User->UserProfile->id to the id of the userprofile to be edited? (I'm not really sure about this since I've never used "saveAll"). Maybe: $userprofileid = $this->User->UserProfile->find(array('user_id' => $this->data['User']['id']),array('id')); $this->User->UserProfile->id = $userprofileid['UserProfile']['id']; $this->User->saveAll($this->data); On Nov 30, 3:02 am, lacithetemplar <[EMAIL PROTECTED]> wrote: > hello, > I have two tables "users" and "user_profiles", which are related . > there's no problem to add new data to this tables, but I don't know > how to edit/update this data. when I use $this->User->saveAll($this->data), > it updates users table, but in the user_profiles it add a new > > entry instead of update current entry. have someone a solution? > thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
update related model data
hello, I have two tables "users" and "user_profiles", which are related . there's no problem to add new data to this tables, but I don't know how to edit/update this data. when I use $this->User->saveAll($this- >data), it updates users table, but in the user_profiles it add a new entry instead of update current entry. have someone a solution? thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---