Hi all, I am quite new in CakePHP. I actually read all the documentation about models, controllers and views in CakePHP. I have been doing some nice programming, but I get stuck on following problem. I have a view which assembles two tables which are realted to each other. Table users has many pnumbers, thus the class User defines a hasMany relation to Pnumber. I want to be able to view a user with all his related pnumbers. For this i do as follows in the users edit view: <?php $pnumbers = $this->data['Pnumber']; foreach ($pnumbers as $pnumber): echo $html->hidden('/Pnumber/id',array('value'=>$pnumber['id'])); echo $html->input('/Pnumber/pnumber', array('size' => '20', 'value' => $pnumber['pnumber'])); endforeach;?>
This gives me all the related pnumbers. User field are listed before ... Now, I think the hidden field and the input field parameters for pnumbers are not set correct in the edit.thml. Could you give me a hint on this? The users controller looks like this: if ($this->User->save($this->data['User'])) if($this->Pnumber->save($this->data['Pnumber'])) $this->flash('Your User has been saved.','/users'); else $this->flash('Failed saving p-number.','/users'); I get following error when i try to save the view Notice: Undefined index: Pnumber in /var/www/html/cake/app/controllers/ users_controller.php on line 22 Failed saving p-number. For completion; my User class looks as follows: class User extends AppModel { var $name = 'User'; var $recursive = 2; var $belongsTo = array( 'Location' => array('className' => 'Location')); var $hasMany = array('Pnumber' => array('className' => 'Pnumber', 'conditions' => '', 'order' => '', 'dependent' => true, 'foreignKey' => 'user_id')); var $validate = array( 'email' => VALID_EMAIL, 'location_id' => VALID_NOT_EMPTY); } What am I doing wrong? What is the easiest way to do this? thanks a lot! Walter. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---