CRUD: [Bug] select2_from_ajax doesn't ever call the function to fetch data
Bug report
It seems that select2_from_ajax never calls the function to fetch data to the dropdown.
What I did
After upgrading Backpack from version 3.6 to 5 (PRO), we have noticed that select2_from_ajax doesn’t work. From debugging, it is apparent that the function bpFieldInitSelect2FromAjaxElement() is never called, and therefore there are never any data returned from any API endpoints.
We had this configuration:
$this->crud->addField([ 'label' => 'Mærke', 'name' => 'brand_id', 'type' => 'select2_from_ajax', 'entity' => 'brand', 'attribute' => 'name', 'model' => Brand::class, 'data_source' => url('api/brands/all'), 'placeholder' => 'Select a car brand', 'minimum_input_length' => 0, 'method' => 'POST', 'attributes' => $this->disabledAttributes(), 'tab' => self::TAB_1, ]);
What I expected to happen
I expected it would call the function and thereby the API endpoint.
What happened
The API endpoint was never called.
What I’ve already tried to fix it
I don’t believe it’s a thing I should fix since it’s a bug in Laravel Backpack.
Is it a bug in the latest version of Backpack?
Yes
After I run composer update backpack/crud the bug… is it still there?
Yes
Backpack, Laravel, PHP, DB version
When I run php artisan backpack:version the output is:
PHP VERSION:
PHP 8.1.7 (cli) (built: Jun 25 2022 08:13:23) (NTS) Copyright © The PHP Group Zend Engine v4.1.7, Copyright © Zend Technologies with Zend OPcache v8.1.7, Copyright ©, by Zend Technologies with Xdebug v3.1.2, Copyright © 2002-2021, by Derick Rethans
LARAVEL VERSION:
v9.19.0@bbce25bd823133f6a5a724f2d62680b711f1d0df
BACKPACK VERSION:
5.1.2@a15f93a784e8d130f5ea5c3341fb7bca1f3c25e3
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (10 by maintainers)
Seems to work! Thank you so much