select2_from_ajax / fetch operation specify key #462
-
Is there any way to specify that a different key is used for a select2_from_ajax field instead of id? I know that using a select2_ajax filter, you can pass in Alternatively can you set what is returned from the fetch operation? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
@emogeekface hey there. I don't think it's needed for the fetch operation as you can control what gets sent with: public function fetchSomething()
{
return $this->fetch([
// configure the fetch here, search operator, columns etc
]);
} Check all options and examples here: https://backpackforlaravel.com/docs/5.x/crud-operation-fetch#how-to-use-1 Let me know if this is not what you are looking for. Cheers |
Beta Was this translation helpful? Give feedback.
-
I'm closing this issue due to inactivity. If you need further assistance or have additional questions, feel free to reopen this issue or create a new one. We're here to help! |
Beta Was this translation helpful? Give feedback.
Sorry @emogeekface I may have missed your question.
That option to provide a different key is not applied to
select2_from_ajax
field, it's locked to get the actual "model" key:So the only way to use other key is if that
$item
is effectively using other key defined in the model.An easy way out is to publish the
select2_from_ajax.blade.php
withphp artisan backpack:field select2_from_ajax_custom_key --from=select2_from_ajax
(you need backpack generators installed to run this command, or you can do it manually.)It will publish a copy of the ajax field to your resource…