How do we make a select2_multiple
sortable? I have a users
table and a badges
table. Naturally, I want to have a user_badge
pivot table which will keep track of all the badges a user has and also sort it based on the order that I define using the select2_multiple
.
Currently, I have my setupCreateOperation()
setup as follows:
protected function setupCreateOperation()
{
$this->crud->addField([
'name' => 'badges_multi',
'label' => 'Badges',
'type' => 'select2_multiple',
'attribute' => 'internal_name',
'entity' => 'badges_multi',
'model' => 'App\Models\Badges',
'pivot' => true,
'sortable' => true,
'sortable_options' => [
'handle' => '.my-custom-handle',
],
]);
}
This returns the select2_multiple
but the input is not sortable, i.e. I can drag and drop to rearrange. It only returns badges in alphabetical order