I started working with Kohana yesterday and there was a problem here.
My default Controller is the "page" and the action is "home". On the "page" controller I have these functions here to set up the layout:
class Controller_Page extends Controller_Index {
public function action_home(){
$this->template->title = "Helpdesk";
$this->template->content = View::factory('home');
}
public function action_newClient(){
$this->template->title = "Helpdesk";
$this->template->content = View::factory('newClient');
}
public function action_listClient(){
$this->template->title = "Helpdesk";
$this->template->content = View::factory('listClient');
}
}
I also have a Controller named "client" and inside it these functions:
class Controller_Client extends Controller_Template {
//put your code here
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('page');
}
}
public function action_lista(){
$cliente = ORM::factory('cliente')->find_all();
$view = View::factory('listClient');
$view->set('clientes',$cliente);
$this->response->body($view);
}
}
In the template that you are putting together, I have a link that points to a form, which in this case is the action_newClient
function of the controller page
where a client is registered, it works fine. In this form, in the action I'm pointing it to the method action_novo
of controller Client
.
How can I redirect to a screen that shows all the results?
>