• 6

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 187


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 187
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

symfony redirect with 2 parameters

how can i redirect to another action passing 2 or more parameters? this code:

$this->redirect('input/new?year=' . $year . '&month=' . $month);

results in URL:


Well, that's normal, "redirect" redirect to an absolute URL. You can do that:

$this->redirect($this->generateUrl('default', array('module' => 'input',
'action' => 'new', 'year' => $year, 'month' => $month)));
  • 56
Reply Report
    • If you have a route defined, you can actually use $this->redirectToRoute('routename', ['param1' => 'value', ['param2' => 'value'])
      • 1
    • If you have a route defined, you can replace 'default' by its name, and change the second parameter with the routes's parameters, if needed.

You can also use redirect, specifying the route name and the parameter array:

$this->redirect('route_name', array('year' => $year, 'month' => $month));

(Tested on Symfony 1.4)

  • 5
Reply Report
$this->redirect('input/new/year/' . $year . '/month/' . $month);
  • -3
Reply Report