Skip to content
Advertisement

Laravel Form displaying correct data but storing incorrect values in DB

I have come across a bug on my website and I am baffled as to how to fix it.. basically I have a view to create courses, I type a course title and secondly assign an instructor to that course and click save. But when i return to my index page.. the instructor i assigned is completely different. It appears there must be an issue with my select but I am not sure how to go about fixing it.. I am new to laravel so any help is greatly appreciated.

I have added a picture to try to further explain my issue, here i have selected an instructor –

enter image description here

And when i return to my index page, the newly created course ‘test’ has the admin user assigned… I am very confused –

enter image description here

create.blade.php

JavaScript

index.blade.php

JavaScript

CoursesController;

JavaScript

}

Referring to latest comment – enter image description here

Advertisement

Answer

you are updating data with key not id

try this

in controller

JavaScript

in blade

you will need instructors->id to update right value

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement