0
votes

Have looked through SO at various Symfony routing issues but no-one seems to have the same issue as this.

Yesterday, routing worked without issue.

Today I am getting errors regarding values being required for arguments with defaults set

This is an example route that is causing me a problem

@Route("/summary/{staffId}", name="task_instance_summary", requirements={"staffId":"\d+"},defaults={"staffId":"0"})

The method definition:

public function summaryAction(Request $request, $staffId)

and of course the error:

"Controller "PlanXL\TaskBundle\Controller\InstanceController::summaryAction()" requires that you provide a value for the "$staffId" argument (because there is no default value or because there is a non optional argument after this one).")

Debug output:

[router] Route "task_instance_summary"

Name task_instance_summary

Path /task/instance/summary/{staffId}

Path Regex #^/task/instance/summary(?:/(?P\d+))?$#s

Host ANY

Host Regex

Scheme ANY

Method ANY

Class Symfony\Component\Routing\Route

Defaults _controller: PlanXLTaskBundle:Instance:summary

staffId: 0

Requirements staffId: \d+

Options compiler_class: Symfony\Component\Routing\RouteCompiler

I have already cleared the cache (even though I am working on dev) but I can't see why I am getting an error. The router can obviously see the default value when I run the debug so why not when called through my application?

1

1 Answers

3
votes

Try it;

public function summaryAction(Request $request, $staffId = 0)