Here is one of my forms which updates a Person model and User
(hasOne), TelephonyNumber (hasMany) and OnlineAddress (hasMany)

Edit View:

echo $form->create('Person');
  echo $form->input('Person.id');
  echo $form->input('Person.title_id');
  echo $form->input('Person.first_name');
  echo $form->input('Person.middle_name');
  echo $form->input('Person.last_name');
  echo $form->input('Person.gender_id');
  echo $this->element('date_jscalendar', array
('id'=>'PersonDateOfBirth', 'model'=>'Person',
'field'=>'date_of_birth', 'label'=>'Date of Birth'));
  echo $form->input('TelephonyNumber.0.id');
  echo $form->input('TelephonyNumber.0.parent_model', array
('type'=>'hidden', 'value'=>'Person'));
  echo $form->input('TelephonyNumber.0.type_id', array
('type'=>'hidden', 'value'=>51));
  echo $form->input('TelephonyNumber.0.number', array
('label'=>'Telephone'));
  echo $form->input('OnlineAddress.0.id');
  echo $form->input('OnlineAddress.0.parent_model', array
('type'=>'hidden', 'value'=>'Person'));
  echo $form->input('OnlineAddress.0.type_id', array('type'=>'hidden',
'value'=>54));
  echo $form->input('OnlineAddress.0.address', array
('label'=>'Email'));
  echo $form->input('User.id');
  echo $form->input('User.username');
  echo $form->input('User.password', array('value'=>'', 'label'=>'New
Password'));
  echo $form->input('User.password_confirm', array('type'=>'password',
'label'=>'Confirm Password', 'value'=>''));
  echo $form->input('User.is_active', array('label'=>'Active',
'options' => array('1' => 'Yes', '0' => 'No')));
  echo $form->input('User.is_deleted', array('label'=>'Deleted',
'options' => array('0' => 'No', '1' => 'Yes')));
  echo $form->input('User.user_group_id');
echo $form->end('Submit');

Controller:

if ($this->Person->saveAll($this->data, array('validate'=>'first'))) {
  $this->Session->setFlash('User updated');
  $this->redirect('view/'.$this->Person->id);
} else {
  $this->Session->setFlash('User not updated, correct errors and
resubmit');
}

Simple, just make sure you have the right ID values included in the
form.

P.S. The TelephonyNumber and OnlineAddress form fields are named
differently due to their hasMany associations
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to