10000 docs(controller): add docs for key option in MapQueryString · symfony/symfony-docs@2fdd0db · GitHub
[go: up one dir, main page]

Skip to content

Commit 2fdd0db

Browse files
committed
docs(controller): add docs for key option in MapQueryString
1 parent 6c341c3 commit 2fdd0db

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

controller.rst

+21
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,27 @@ HTTP status to return if the validation fails::
443443

444444
The default status code returned if the validation fails is 404.
445445

446+
If you want to map your object to a nested array in your query with a specific key,
447+
you can use the ``key`` option in your :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryString`
448+
attribute::
449+
450+
use App\Model\SearchDto;
451+
use Symfony\Component\HttpFoundation\Response;
452+
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
453+
454+
// ...
455+
456+
public function dashboard(
457+
#[MapQueryString(key: 'search')] SearchDto $searchDto
458+
): Response
459+
{
460+
// ...
461+
}
462+
463+
.. versionadded:: 7.3
464+
465+
The ``key`` option of ``#[MapQueryString]`` was introduced in Symfony 7.3.
466+
446467
If you need a valid DTO even when the request query string is empty, set a
447468
default value for your controller arguments::
448469

0 commit comments

Comments
 (0)
0