Welcome Guest, Not a member yet? Register   Sign In
Calling one method from another within the same controller
#1

[eluser]Unknown[/eluser]
I'm trying to add error messages and prompts at the top of pages, rather than redirecting to new pages.

For instance, when I link to 'user/delete', I tell my controller to load an alert variable, and then run the usual 'user/view' method:

Code:
function delete()
{
    $this->load->vars('alert','Are you sure?');
    $this->view();
    return;

    [...]

(I'm "paraphrasing" my code here, there's more to it than that.)

Note that I have use 'return' to keep CI from continuing through the delete function. This works, but it really doesn't feel like the best way of doing this.

I was using $this->session->set_flashdata() for the alert and then redirecting to 'user/view', but that seems even worse since it requires a redirect that slows things down (right?).

Thanks for any advice.


Messages In This Thread
Calling one method from another within the same controller - by El Forum - 02-10-2011, 06:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB