Support the ongoing development of Laravel.io →
posted 10 years ago
Input Forms
Last updated 2 years ago.
0

I guess you could pass in a flag to prevent empty submissions, but to me just because an input is an empty string doesn't mean it shouldn't by a method called all()... going by the name it should return all, not most()....

You could feature request input::all(hasValue=true) which would return all where there is a value, but the default behavior of all() should be to return all.

Last updated 2 years ago.
0

Yeah, Input::all() should return all posted data, not just non-empty strings. array_filter() by default filters out falsey values, so if you really need a one-liner, you could probably do something like:

$input = array_filter(Input::all());

But the default behavior should definitely be to return everything, because, generically speaking, an empty string is a valid input value.

EDIT: In addition to that, what would you want to do with submitted empty arrays, or arrays with empty strings, etc.? Basically, there's no clear answer, it depends on the circumstances, and a framework-level method like this shouldn't interfere with a developer's business logic - it's on you to decide what you do with your input. And if you really want to, you can always just make your own request class and override that method to return array_filter(parent::all()) - see here on info about extending the Request class: http://laravel.com/docs/extending#request-extension

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

EloProf eloprof Joined 9 Sep 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.