Uuummmmmmm, I must say I don't really understand what your problem
precisely is, however I can spot a few mistakes in the code you
provided;

* using the HtmlHelper the tagName param should be User/id, not User/
user_id (that's if you're using the cake naming conventions)
* also if your relations are defined properly, you shouldn't have to
$this->data['User']['profile_id']=array($this->Profile-
>getLastInsertId());

if I understand your app properly (Please, provide more details!) you
should have something like this for a one to one relationship;

User Model:
$hasOne = array('Profile');

Profile Model:
$belongsTo = array('User');

However, I see you have a Users_Profiles, meaning your having a many
to many relationship...??!

If that's the case, make sure your table is named Profiles_Users
(alphabetical) and you should not have a profile_id in the user table
nor in the user model.

Then try that; (assuming you have used the proper naming conv...!)

User Model:
var $hasAndBelongsToMany = array('Profile');

and the Profile Model should have the reverse;
var $hasAnd BelongsToMany = array('User');


So anyway, again, I'm really not sure where you're heading... but post
some more code (models, views and tbl structure) and we'll see what we
can do!

Hope it helps!

Seb./

Kathrin wrote:
> Hello,
> ich have Problems to save data in a hasMany/belonsto
> Users_ProfilesTable.
> Sie Array is OK.
> My source:
>
> View User:
> <?php // echo $html->hidden('User/user_id', array('value' =>
> $post['User']['id']));?>
> post to  User/Controller save the data and post user_id to Profile/
> controller
> View/Profile
> echo $form->hidden('User/user_id', array('value'=> $userid));
> Controller/Profile
> function addprofile($userid=0) {
>                               $this->set('userid',$userid);
>                 if (!empty ($this->data)) {  #Formular wurde
> abgeschickt->eingegebene Datenspeichern
>                         $this->cleanUpFields();
>                         $this->Profile->create();
>                       
> $this->data['Profile']['user_id']=array($this->data['User']
> ['user_id']);
>                         $this->Profile->save($this->data);
>                       $this->data['User']['profile_id']=array($this->Profile-
> >getLastInsertId());
>                       //error_log(print_r($this->data,true));
>                       $this->Session->setFlash('The Profile-Data has been 
> saved');
>                         exit();
>                 }
> Have somebody an idea?
> Sincerely Kathrin


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to