Reputation: 93
I'm having trouble creating a Regex to match URL slugs [a-z] ("words" separated by single dashes) like this:
wordone-wordtwo-wordtree
in route:
csa_platform_category:
path: /c/{slug}
defaults: { _controller: CSAPlatformBundle:Category:index }
requirements:
slug: "^[a-z]+(?:-[a-z]+)*$"
in twig:
<a href="{{ path('csa_platform_category', {'slug': cat.slug}) }}">{{ cat.name }}</a>
The displayed error is:
An exception has been thrown during the rendering of a template ("Parameter "slug" for route "csa_platform_category" must match "[a-z]+(?:-[a-z]+)*" ("" given) to generate a corresponding URL.").
I'm quite bad with regular expressions, so any help would be appreciated.
Upvotes: 1
Views: 1123
Reputation: 8162
The error you are having is saying than your cat.slug
is empty.
("" given)
You should check the data in cat object using var_dump
or dump
Upvotes: 2