Laravel Eloquent - Options for fields of select type
Laravel Eloquent - Options for fields of select type
Hi, I have a BollaAcquisto model that have a foreign key 'fornitore_id' in Fornitore table.
In laravel, I have defined that relationship:
public function fornitore(){
return $this->hasOne('Modules\Prodotto\Entities\Fornitore', 'id');
}
In query() function of BollaDataTable class, I have:
public function query(BollaAcquisto $model)
{
return BollaAcquisto::with('fornitore')->select('bolla_acquisto.*');
}
When I show the datatable, I have the fornitore.nome instead of fornitore_id, right.
The fornitore.nome field, in the editor, have type=select, so I would select the fornitore_id value from Fornitore table.
If I click on the select, no options are shown. So, how I can specify the options to Datatables editor?
Thanks a lot
Answers
This example shows an example of the options for a
select
field.https://editor.datatables.net/examples/simple/fieldTypes.html
The docs are here:
https://editor.datatables.net/reference/field/select
Its not clear to me if you are building the options list. Maybe you can post your Editor code and an example of the options you are building.
Kevin
Thanks for the answer.
The question is where I can define the options for select fields.
My app is build in Laravel; the js in index.blade.php:
This the code in BollaDataTable.php
The BollaDataTablesEditor.php has empty functions.
I'va used this tutorial: https://yajrabox.com/docs/laravel-datatables/master/editor-tutorial
Thanks.