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

Lines changed: 21 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy