1
I’m trying to edit a record in Cakephp 3 and instead of editing the system, it’s inserting a new record.
Staticscontroller.php
public function editar($ID){
    $estatisticasTable = TableRegistry::get('Estatisticas');
    $estatistica = $estatisticasTable->get($ID);
    $this->set('estatistica', $estatistica);
    $this->render('nova');
}
Text of index.ctp that is in Template Statistics index.ctp
echo $this->Html->Link('Editar', ['controller' => 'estatisticas','action' => 'editar', $estatistica['ID']]);
Code to Save:
function salva(){ 
    $estatisticasTable = TableRegistry::get('Estatisticas'); 
    $estatistica = $estatisticasTable->newEntity($this->request->data()); 
    if($estatisticasTable->save($estatistica)){ 
        $msg = "Estatística Salva com Sucesso";
        $this->Flash->set($msg, ['element' => 'success']); 
    } 
    else { 
        $msg = "Erro ao tentar Salvar"; $this->Flash->set($msg, ['element' => 'error']); 
    } 
    $this->redirect('/Estatisticas/index'); 
}
						
And where is the rescue code. It seems to me that you didn’t put it there.
– Wallace Maxters
@fabricio_wm edit your question and put the code there, to be better visible
– Jeferson Assis
Try to use update
– Williams