failed to perform update in CakePHP

1

I'm trying to edit a record in CakePHP 3 and instead of editing it, it's inserting a new record. StatisticsController.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'); 
}
    
asked by anonymous 11.09.2015 / 15:34

0 answers