-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[HttpKernel] Explain how to define default value in MapQueryString #19627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HttpKernel] Explain how to define default value in MapQueryString #19627
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Neil!
I think this is correct, but I'll wait for other reviews before merging.
@@ -451,6 +451,24 @@ HTTP status to return if the validation fails:: | |||
|
|||
The default status code returned if the validation fails is 404. | |||
|
|||
If the request query string is empty and if you still need to have a valid DTO, you can | |||
define a default value in your controller method:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define a default value in your controller method:: | |
define a default value to your controller parameter:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tweaked this while merging ... but apparently, the correct preposition here is for
instead of to
😊 Thanks!
In this case your DTO should have default values. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this line may be superfluous 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I removed it while merging. Thanks.
Neil, thanks a lot for this improvement ... and congrats on your first Symfony Docs contribution 🎉 |
Hello,
The current example of how using a
MapQueryString
attribute is not really clear about default DTO value. Some people expects to have a new instance of their DTO.The goal of this PR is to add a bit of details about how to define this default value.
see #54042