as you can see, this is the show method in my PropertyController:
/**
* @Route("/biens/{slug}-{id<\d >}", name="property.show", requirements={"slug": "[a-z0-9\-]*"})
* @return Response
*/
public function show($slug, $id): Response
{
$property = $this->repository->find($id);
return $this->render('property/show.html.twig', [
'property' => $property,
'current_menu' => 'properties'
]);
}
and in my home.html.twig file, this is a part of my code:
<a href="{{ path('property.show', {slug: property.slug, id: property.id}) }}">{{ property.title }}</a>
however I don't really understand why I get this error message when I try to access the link eventhough hovering over the link I can see my url.
CodePudding user response:
You can try it:
@Route("/biens/{slug}/{id}", name="property.show", requirements={"slug": "[a-z0-9\-]*", "id": "\d "})
CodePudding user response:
Try this, it worked for me:
/**
* @Route("/biens/{slug}-{id}",
* name="property.show",
* requirements={
* "slug": "[a-zA-Z0-9\-]*",
* "id": "\d "
* }
* )
* @return Response
*/
You need to add A-Z in your regex because of "Mon-premier-bien-1"