Closed argb closed 6 years ago
Obviously we supposed to get the default value ddd if the nickname is empty
How is that obvious? You have specified a value, it just happens to be null. (It was probably an empty string that a middleware changed into null.) Are you looking for $request->input('nickname') ?? 'ddd'
?
So a little more detail would help. If memory serves, empty strings and null are perfectly acceptable values in this situation, so if the key exists and has a value of null or empty string, then that is what you receive, not the default. The default is in case the attribute doesn't exist at all in the given data.
@sisve @devcircus Thank you both, maybe I misunderstanding what the "DEFAULT" means, I thought it as default while i got an empty value, which include unsetted field, null, and empty string. Now i got it. Here the default value is triggered only while there are no the corresponding fields.
Description:
The default value of a request parameter doesn't work in laravel5.5 Such as the most simple code in any controller.
dd($request->input('nickname', 'ddd'));
Obviously we supposed to get the default value ddd if the nickname is empty, but unfortunately we will dump a null value. Is laravel5.5 tested fully before release?
Steps To Reproduce: