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.
csa_platform_category: path: /category/{slug} defaults: { _controller: CSAPlatformBundle:Category:index } requirements: slug: "~^[a-z]+(?:-[a-z]+)*$~" – emwww Dec 29 '16 at 13:37