'Backpack Laravel select2_from_ajax field returns results, but I can't select any

I'm implementing a 'select2_from_ajax' field using Backpack for Laravel.

I've implemented this in other places and it works correctly. But for some reason when implementing it this time it will not let me select any of the options and doesn't show the highlight when mousing over the options. It lists out the options correctly, I just can't select any of them.

The only thing I can think of is that the relationship it's trying to reference doesn't have a primary 'id' field in the database, but I'm not sure why that would affect this.

I have implemented both the index and show routes.



Solution 1:[1]

The issue was that the relationship field's primary key was not 'id' it was setup with a different column name.

I reworked the data structure so the foreign key referenced was pointing to a column labeled 'id'.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 James Parker