Quote:- Did you save the 'student' object first? - Have you looked through the troubleshooting section in the docs? - Have you looked at the queries being generated to see what's happening? - Have you double-checked the names of your fields?
class User extends DataMapper { var $has_one = array( 'guardian' => array( 'class'=>'user', 'other_field' => 'student' )); var $has_many = array( 'student' => array( 'class' => 'user', 'other_field' => 'guardian' ), //.........
$user = new User(); $guardian = new User(); $user->salutation = $this->input->post('salutation'); $user->firstname = $this->input->post('firstname'); $user->middlename = $this->input->post('middlename'); $user->lastname = $this->input->post('lastname'); $guardian->get_by_id($this->input->post('guardian')); if(!$user->validate()) { foreach ($user->error->all as $errors) { echo $errors; } }else{ $user->save(); if(!$guardian->save_student($user)) foreach ($guardian->error->all as $errors) { echo $errors; } } //..........