3
I have a screen where I receive a parameter (id) and from it I mount a form. After saving this form I need to go back to the previous screen to display what was saved. How can I do this? I’ve tried several ways, several Requests but nothing works.
Form:
<form name="cad_user" id="cad_user" action="/user/novo" method="post">
<div class="modal-body">
<input type="hidden" id="txtCadUsrId" value="">
<label for="txtEdtUsrNomTop">Nome</label>
<input type="text" id="nome" name="nome" class="form-control">
<label>Email</label>
<input type="text" id="email" name="email" class="form-control">
<label>Senha</label>
<input type="password" id="pass" name="pass" class="form-control">
<label>Repita a senha</label>
<input type="password" id="pass2" name="pass2" class="form-control">
<input type="hidden" name="codCliente" id="codCliente" value="<?php echo $clientes['cliente']->id ?>" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
<button id="Cadastro" type="submit" class="btn btn-primary">Cadastrar</button>
</div>
</form>
Action registered in the bank:
public function action_novo(){
$cliente = ORM::factory('cliente');
$cliente->nomeCliente = $this->request->post('nomeCliente');
$cliente->cnpjCliente = $this->request->post('cnpjCliente');
$cliente->dataCadastro = date("Y-m-d H:i:s");
if($cliente->save()){
$session = Session::instance();
$session->set('msg', 'Cliente cadastrado com sucesso!');
$this->redirect('admin/listClient');
}
}
With save, it could be in form Submit?
– Samir Braga
What do you mean? Save normal saves, I need you to go back to the previous screen and list all that has been saved understand?
– Daniel Swater
But this form is in a lightbox or another page?
– Samir Braga
The form is in a modal, after doing Submit it goes there and saves, when it comes back , I don’t need the modal to appear
– Daniel Swater
A command to give a refresh serveria?
– Samir Braga
Yes, I believe so, at least I think
– Daniel Swater
I’ll leave an answer with a code.
– Samir Braga
Okay, here I test
– Daniel Swater