Return to the previous screen after registering using Kohana

Posted on

Question :

I have a screen where I get a parameter (id) and from it I mount a form. After saving this form I need to return to the previous screen to display what was saved. How can I do this? I have tried in many ways, several Requests but nothing works.


<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">
                <input type="text" id="email" name="email" class="form-control">
                <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 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>

Action that registers 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");
        $session = Session::instance();
        $session->set('msg', 'Cliente cadastrado com sucesso!');            



Answer :

Problem solved.

I put this code in the action:



Leave a Reply

Your email address will not be published. Required fields are marked *