@vusumzi make this changes in your code
<option value="">Choose...</option>
and in your controller
'province' => 'required',
and also check your header form data in network tab, for any values is there in the name of province
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I was trying to validate a form, but it seems that I cant show the error message for the dropdown field.
here is my updade.blade.php
<div class="form-group">
<select id="province" name="province" class="form-control @error('province') is-invalid @enderror" >
<option>Choose...</option>
<option value="Western Cape" {{ ($user->learner->province == "Western Cape") ? 'selected' : ''}}>Western Cape</option>
<option value="Northern Cape" {{ ($user->learner->province == "Northern Cape") ? 'selected' : '' }}>Northern Cape</option>
<option value="Eastern Cape" {{ ($user->learner->province == "Eastern Cape") ? 'selected' : '' }}>Eastern Cape</option>
<option value="North West" {{ ($user->learner->province == "North West") ? 'selected' : '' }}>North West</option>
<option value="Free State" {{ ($user->learner->province == "Free State") ? 'selected' : '' }}> Free State</option>
<option value="Kwazulu Natal" {{ ($user->learner->province == "Kwazulu Natal") ? 'selected' : '' }}>Kwazulu Natal</option>
<option value="Gauteng" {{ ($user->learner->province == "Gauteng") ? 'selected' : '' }}>Gauteng</option>
<option value="Limpopo" {{ ($user->learner->province == "Limpopo") ? 'selected' : '' }}>Limpopo</option>
<option value="Mpumalanga" {{ ($user->learner->province == "Mpumalanga") ? 'selected' : '' }}>Mpumalanga</option>
</select>
@error('province')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
and here is the update method from the UserController
public function update(Request $request, $id)
{
$this->validate($request,[
'email' => 'email',
'phone' => 'min:10|max:15',
'gender' => 'required',
'identity' => 'required',
'password' => 'string|min:8|confirmed',
'street' => 'required',
'suburb' => 'required',
'city' => 'required',
'province' => 'required|not_in:0',
'code' => 'required',
'school' => 'required',
'grade' => 'required|not_in:0'
]);
$user = User::find($id);
$user->update($request->all());
if($user->types == 'Learner'){
$learner = Learner::where('user_id',$id)->first();
$learner->gender = $request->input('gender');
$learner->identity = $request->input('identity');
$learner->street = $request->input('street');
$learner->suburb = $request->input('suburb');
$learner->city = $request->input('city');
$learner->province = $request->input('province');
$learner->code = $request->input('code');
$learner->school = $request->input('school');
$learner->grade = $request->input('grade');
$learner->save();
return redirect()->back()->with('message','User Updated Successfully');
}
}
I want the error message to be displayed at the bottom of the select field and the field to have a red border around... Its working fine for other input fields but the problem is the select field...
Please or to participate in this conversation.