簡単なリクエスト/受け入れ機能を作成しようとしています。ユーザーが人物を追加します - 両方のユーザーのユーザー名が、自動生成された ID とともにテーブルに追加されます。他のユーザーがリクエストを確認すると、承認をクリックしてレコードに有効期限を追加します。現在何が起こっているかというと、ユーザーが同意をクリックして有効期限を設定すると、関係テーブルに新しいレコードが作成されます。
私の関係テーブルの構造は
id
partyone
partytwo
active
expirydate
パブリック関数 add(){
if($this->request->is('post')){
$this->Relationship->create();
if ($this->Relationship->save($this->request->data))
{
$id=$this->Relationship->id;
$this->Session->setFlash('The relationship has been saved');
}
else { $this->Session->setFlash('The relationship could not be saved. Please, try again.'); }
}
}
public function approve(){
if($this->request->is('post')){
$this->Relationship->id;
$this->Relationship->getLastInsertID();
$this->Relationship->save($this->request->data);
$this->Session->setFlash('The information has been saved');}
else{
$this->Session->setFlash('The information couldnt be saved');}
}
}
ここに私の承認ビューがあります
<?php
echo $this->Form->create('Relationship', array('action'=>'approve'));
echo $this->Form->input('expirydate',array('label'=>'Expiry Date: ', 'class' => 'dateclass'));
echo $this->Form->end('Submit');
?>
これが私の追加ビューです
<?php
echo $this->Form->create('Relationship', array('action'=>'add'));
echo $this->Form->input('partyone',array('label'=>'Enter your username: '));
echo $this->Form->input('partytwo',array('label'=>'Username of user: '));
echo "<br />";
echo $this->Form->end('Click here to add relationship');
?>
これを更新して有効期限のある新しい行を作成しないようにコーディングするにはどうすればよいですか。