I wanted to make function, which after clicking in button will change status of some task to finished.
First of all i have problems with updating filed.
Code of function:
public function change_status($id=null){
if($this->request->is('get')){
throw new MethodNotAllowedException();
}
if($this->Task->change_status($id)){
$this->Task->id = $id;
$this->Task->saveField('status', 'Finished');
}
}
Code of button
echo ('<i class="fa fa-times-circle"></i> '.$this->Form->postLink('ChangeStatus', array('action' => 'change_status', $task['Task']['ID']), array('confirm' => 'Are You want to change status of this task?')));
And in database theh field Status is a varchar(25) with default "To Do"
The error is
Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'change_status' at line 1
Thanks for any help in advance.
Try This:
public function change_status($id=null){
if($this->request->is('post')){
$this->Task->id = $id;
$this->Task->saveField('status', 'Finished');
}else{
throw new MethodNotAllowedException();
}
}