I am running Laravel 8 and when I select an item from my dropdown, It just chooses the default text from the first option even if it is disabled and storing that in the Database. I am sure I am missing something. Any one can help me with this will be much appreciated.
here is one of my select items:
<select name="last_page_viewed[]" type="number" class="form-control" placeholder="Enter page number">
<option disabled>Please Select a Page</option>
<option value='Technology Vocabulary'>42</option>
<option value='Technology Vocabulary'>43</option>
<option value='Technology Vocabulary'>44</option>
<option value='Technology Vocabulary'>45</option>
<option value='Technology Vocabulary, Compound Nouns'>46</option>
<option value='Relative Clauses - Defining and Non Defining'>
47
</option>
<option value='Briefing'>48</option>
</select>
In my controller I have the following:
public function PerformanceAdd() {
$data['students'] = User::where('teacher_id', Auth::user()->id)->get();
// get id of level where level_id matches with user_id using model relationship
$data['levels'] = Level::with('student')->where('id', 'level_id')->get();
// get list of all exam titles to show on permormance_add view
$data['exam_titles'] = Oex_exam_master::get()->all();
return view('admin.performance.performance_add', $data);
}
public function PerformanceStore(Request $request) {
$countstudent = count($request->student_id);
if($countstudent !=NULL) {
for($i=0; $i < $countstudent; $i++) {
$perform = new Performance();
$perform->teacher_id = Auth::user()->id;
$perform->date = $request->date;
$perform->last_unit_covered = $request->last_unit_covered[$i];
$perform->student_id = $request->student_id[$i];
$perform->last_page_viewed = $request->last_page_viewed[$i];
$perform->student_progress = $request->student_progress[$i];
$perform->exam_type = $request->exam_type[$i];
$perform->exam_score = $request->exam_score[$i];
$perform->comments = $request->comments[$i];
$perform->save();
}
}
$notification = array(
'message' => 'Students Performance Successfully Submitted.',
'alert-type' => 'success'
);
return Redirect()->back()->with($notification);
}
Thanks in advance for any help on this. By the way, all the other data is getting to the db just fine.
EDIT:: I added Value='' and it started working.