TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
redirect with error validation result
  • I have an action in controller /account/list_projects - to view list of projects and form to add new.
    After adding new project the form go to /account/add_project, in which i do validation of POST, and
    after collecting errors i want to use Request::instance()->redirect('/account/list_blogs'); but with saving
    errors:

    $errors = $users_project->validate()->errors('addproject');
    $this->template->errors = $errors;

    ...

    Yes i may not to use redirect but the url in address will be "/account/add_project", not the needed "account/list_projects"
  • i think that i can do it with sessions, but how realize it in pretty way ?
  • you are in bad practice way there's no pretty way to solve.

    if you want to put the list view and a new form view together, why not combine add_project and list_projects into one action? no redirect need.

    something like thatpublic function action_projects()
    {
    if( ! empty($_POST))
    {
    $errors = $this->add_project();
    }
    else
    {
    $errors = NULL;
    }
    $this->list_project($errors);
    }
    protected function add_project()
    {
    return validate::check;
    }
    protected function list_project($errors)
    {
    View::render();
    }