Open jicksonjohnson opened 3 years ago
another update,
I haven't mentioned that, I am using this select inside form hasMany also this form is a step form ( using class Encore\Admin\Widgets\StepForm; )
$form->hasMany('purchased_items','Purchased Items', function (NestedForm $form) use ($products) { $form->select('item_id', 'SKU')->match(function ($keyword) { return Product::where('sku', 'LIKE', '%' . $keyword . '%') ->select([DB::raw('sku AS text'), DB::raw('product_id AS id')]) ->latest(); }); });
I found the select is working fine if I use inside a normal admin form
found that processResults
of select2 JS extended inside LaravelAdminExt\Select2\Traits\FormTrait is not calling or working while using select inside stepForm
I will look into this issue ASAP but not now (maybe tomorrow), because it's last day of chinese spring festival. sorry
thank you so much for replying. when you become free, please have a look.
between I am adding few info. not sure whether these will help to find the cause.
the extended select is working fine while we use inside a normal admin form ( use Encore\Admin\From )
its not working while we use inside a hasMany relation in any form type
`local.ERROR: Call to undefined method Illuminate\Database\Eloquent\Builder::toJson() {"userId":1,"exception":"[object] (BadMethodCallException(code: 0): Call to undefined method Illuminate\Database\Eloquent\Builder::toJson() at /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:50) [stacktrace]
I see that, it is a bug, maybe there's no stepForm
that while, when this plugin initialized.
And it must support inside stepForm anyway, or it is so fail to tell other it is powerful extension.
Fix soon.
$form->select('item_id', 'SKU')->match(function ($keyword) { return Product::where('sku', 'LIKE', '%' . $keyword . '%')->select([DB::raw('sku AS text'), DB::raw('product_id AS id')])->latest(); });
the above code not giving me any listing. Showing "Result could not be loaded" message always.
just for your reference, below is the actual code I was using before.
$products = DB::table('products')->pluck('sku','product_id')
$form->select('item_id','SKU')->options($products)->rules('required');
I am trying your package only because speed up the search process. the total records of products I have is 30K + and listing all in select box is causing load issue and making it as a searchable result is a better solution.