I'm doing a CRUD all in my INDEX but I'm having trouble with the bootstrap modal parts. I made an EDIT button where it gets id but when I click it it always follows the modal empty.
<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;
}