8000 minor #10785 [Router] Marking variable as important (zavulon) · symfony/symfony-docs@06b8e9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 06b8e9b

Browse files
committed
minor #10785 [Router] Marking variable as important (zavulon)
This PR was merged into the master branch. Discussion ---------- [Router] Marking variable as important symfony/symfony#29599 Commits ------- 34f5dfa [Router] Marking variable as important
2 parents 02465f8 + 34f5dfa commit 06b8e9b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

routing.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,18 @@ So how can you make ``blog_list`` once again match when the user visits
531531
Now, when the user visits ``/blog``, the ``blog_list`` route will match and
532532
``$page`` will default to a value of ``1``.
533533

534+
If you want to always include some default value in the generated URL (for
535+
example to force the generation of ``/blog/1`` instead of ``/blog`` in the
536+
previous example) add the ``!`` character before the placeholder: ``/blog/{!page}``
537+
538+
.. versionadded:: 4.3
539+
The feature to force the inclusion of default values in generated URLs was
540+
introduced in Symfony 4.3.
541+
542+
When you generate URL for path ``blog_list`` without adding ``page`` parameter Router
543+
will generate ``/blog/``. Note that it doesn't use default value ``1``. To generate
544+
``/blog/1`` mark variable as important adding ``!`` before the name: ``/blog/{!page}``.
545+
534546
As it happens with requirements, default values can also be inlined in each
535547
placeholder using the syntax ``{placeholder_name?default_value}``. This feature
536548
is compatible with inlined requirements, so you can inline both in a single

0 commit comments

Comments
 (0)
0