Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Issue with different View
  • Hi guys,

    I'm running some DB operations in my app and want to show the user a confirmation site before the actual delete operation takes place.

    Until now I did justa few simple fuel apps and was getting along with templates and views quite well.

    But in this case I just don't seem to get it. Said simple I want to show the user View::forge('tools/purgeconfirm', $data) once processing is done. But it seems that no matter what I do they always get presented the default view 'tools/purge' after sending POST.



    public function action_purge()
    {

    if (Input::method() == 'POST')
    {
    $val = Model_Tool::validate_dupes('purge');
    if ($val->run())
    {

    // Lots of processing, POST handling, filling arrays from model etc.
    // ...


    // OUTPUT

    // This works - BUT I get a blank page without styles etc.
    return Response::forge(View::forge('tools/purgeconfirm', $data));

    // Using this I end up at tools/purge view as if no POST had happened before
    $this->template->content = View::forge('tools/purgeconfirm', $data);

    }
    }
    else
    {
    Session::set_flash('error', $val->error());
    }
    }

    // This is where I always seem to end
    $this->template->title = "Cleanup";
    $this->template->content = View::forge('tools/purge');
    }
  • Sorry to say, but this is pretty obvious. ;-)

    After you have set $this->template->content to your confirm View, the code continues down, to where it sets the title, and then overwrites $this->template->content.

    So you better move it to the top:

    public function action_purge()
    {
        // make this the default
        $this->template->title = "Cleanup";
        $this->template->content = View::forge('tools/purge');

        if (Input::method() == 'POST')
        {
            $val = Model_Tool::validate_dupes('purge');
            if ($val->run())
            {
                // Lots of processing, POST handling, filling arrays from model etc.
                // ...


                // override the default set above
                $this->template->content = View::forge('tools/purgeconfirm', $data);
            }
            else
            {
                Session::set_flash('error', $val->error());
            }
        }
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion