Return to the previous screen after registering using Kohana

Asked

Viewed 1,599 times

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?

  • 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?

  • But this form is in a lightbox or another page?

  • 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

  • A command to give a refresh serveria?

  • Yes, I believe so, at least I think

  • I’ll leave an answer with a code.

  • Okay, here I test

Show 3 more comments

1 answer

5

Problem solved.

I put that code into action:

HTTP::redirect('admin/detailClient/'.$this->request->post('codCliente'));
  • I was gonna tell you to put that onclick="window.location.Reload()", but never mind :).

  • Beauty buddy, anyway thank you so much

  • You can mark your reply as accepted by clicking on the tick sign below the response points.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.