profileController を使用する Vake プロジェクトの profile.ctp にプロファイルの編集ページがありますか? URL、電話などの入力フィールドを追加したいのですが、ユーザーはより多くの電話を持つことができるので、users_phones という別のテーブルを作成しました
USERS_PHONES
id
user_id
phone
私の見解では、フォームを作成しました
<?
echo $this->Form->create();
echo $this->Form->input('UsersPhones.phone');
echo $this->Form->end('Save');
?>
モデルには次のものがあります:
public $hasMany = array(
'Phones' => array(
'className' => 'UsersPhones',
'foreignKey' => 'user_id',
'dependent' => true
)
);
コントローラ:
$this->User->id = $this->Auth->user('id');
if ($this->request->is('post')) {
if ($this->User->save($this->request->data, array('validate' => false))) {
$this->Session->setFlash('Profile updated succsessefully!',
'default', array('class' => 'okmsg'));
$this->redirect($this->request->here);
} else {
$this->Session->setFlash('Profile could not be saved. Please, try again.',
'default', array('class' => 'errormsg'));
}
}
しかし、SAVEをクリックしてもusers_phonesに挿入されません