Skip to content

Commit

Permalink
Merge branch '6.4' into 7.0
Browse files Browse the repository at this point in the history
* 6.4:
  Minor reword
  [HttpKernel] Explain how to define default value in MapQueryString
  • Loading branch information
javiereguiluz committed Mar 12, 2024
2 parents 3ba9aef + 6780781 commit e9a379e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,22 @@ HTTP status to return if the validation fails::

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

If you need a valid DTO even when the request query string is empty, set a
default value for your controller arguments::

use App\Model\UserDto;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;

// ...

public function dashboard(
#[MapQueryString] UserDTO $userDto = new UserDTO()
): Response
{
// ...
}

.. _controller-mapping-request-payload:

Mapping Request Payload
Expand Down

0 comments on commit e9a379e

Please sign in to comment.