I am using Laravel Collective for creating my webform.
{!! Form::select('сity_from', ['London', 'Tokyo', 'Moscow'], null, ['placeholder' => 'Choose city'] ) !!}
which produces the following html:
<select id="сity_from" name="сity_from">
<option selected="selected" disabled="disabled" hidden="hidden" value>Choose city</option>
<option value="London">London</option>
<option value="Tokyo">Tokyo</option>
<option value="Moscow">Moscow</option>
when I choose no city and submit form, and then dd($request->all());
in Controller
i can see nothing, I mean, there is no $request->all()['city_from']
;
I would like to get ['city_from' = null]
in this case.
I suppose I have to change 'value' in
<option selected="selected" disabled="disabled" hidden="hidden" value>Choose city</option>
to value="null"?
Or something else?
I would like to be using Laravel Collective when solving this problem.
I suggest you to not bother with the presence of 'city_from' in your request.
You might use $cityForm = $request->input('city_from');
And you will have $cityForm
set to the actual value, or to null
public function store(Request $request)
{
$cityForm = $request->input('city_from'); //will always be actual value or null
}