3
I’m doing a CRUD all on my INDEX but I’m having trouble in the bootstrap modal parts. I made an EDIT button where it receives id but when I click it always brings the modal vázio.
<a data-toggle="modal" data-target="#myModal2" class="btn btn-default" role="button" href="editar/<?=$cliente['Cliente']['id'];?>">Alterar</a>
my controller:
public function editar($id = null) {
if (!$id) {
throw new NotFoundException(__('<div class="pull-right"><div class="alert alert-success"><strong>Erro entre em contato com o suporte.</strong></div></div>'));
}
$cliente = $this->Cliente->findById($id);
if (!$cliente) {
throw new NotFoundException(__('<div class="pull-right"><div class="alert alert-success"><strong>Erro entre em contato com o suporte.</strong></div></div>'));
}
if ($this->request->is('post') || $this->request->is('put')) {
$this->Cliente->id = $id;
if ($this->Cliente->save($this->request->data)) {
$this->Session->setFlash(__('<div class="pull-right"><div class="alert alert-success"><strong>Cliente atualizado com sucesso.</strong></div></div>'));
$this->redirect(array('action' => 'index'));
}
}
if (!$this->request->data) {
$this->request->data = $cliente;
}
$this->autoRender = false;
}