I followed this guide of simplifying the controller. Sharing one form between create and edit
The old() helper is not working as expected with the <select>.
Every time I submit the form when something is missing, the old selected option is there, but when I resubmit the form, it shows an error that the <select> field is required…
The string inputs is as follows:
<input type="text class="form-control @error('claimedBy') is-invalid @enderror" name="claimedBy" value="{{ old('claimedBy', $lostFound->claimedBy) }}">
But the select is like this:
<select class="form-select select-basic-single @error('handover') is-invalid @enderror" name="handover">
<option value="{{ old('handover', $lostFound->handover ?? 'null') }}" selected disabled>{{ old('handover', $lostFound->handover ?? 'Handed to') }}</option>
<option value="police"> Police </option>
<option value="owner"> Owner </option>
<option value="warehouse"> In Warehouse </option>
</select>
Make the option value null and the text Handed to if no value is selected.
>Solution :
Try removing the disabled from the option. A disabled option will not be submitted.
There is a missing comma in your input field by type="text"
old
type="text class="form-control @error('claimedBy') is-invalid @enderror"
new
type="text" class="form-control @error('claimedBy') is-invalid @enderror"

