ユーザーとアーティストの 2 つのテーブルがあります。
User:
id
name
password
city_id
state_id
country_id
Artist:
id
user_id
description
追加および編集フォームを作成したい (単一のフォームが追加および編集として機能する)。しかし、編集リンクをクリックすると、ユーザーとアーティストテーブルのフォームフィールドに入力したいと思います。それ、どうやったら出来るの?以下は私のコントローラーコードです:
public function artist_register() {
$this->country_list();
if ($this->request->is('post')) {
$this->request->data['User']['group_id'] = 2;
if ($this->{$this->modelClass}->saveAll($this->request->data)) {
$this->redirect(array('controller' => 'Users', 'action' => 'login'));
}
}
$this->render('artist_update');
}
public function artist_update($id) {
$artist = $this->{$this->modelClass}->findByuser_id($id);
$artist_id = $artist[$this->modelClass]['id'];
if($this->request->is('get')) {
$this->request->data = $this->{$this->modelClass}->read(null, $artist_id);
$this->request->data = $this->{$this->modelClass}->User->read(null, $id);
} else {
if($this->{$this->modelClass}->save($this->request->data)) {
$this->Session->setFlash('Your Profile has been updated');
$this->redirect(array('action' => 'index'));
}
}
}
コードが機能しません。どうすれば解決できますか?