Problem with select2_from_ajax_multiple
See original GitHub issueI have a field with a select2_multiple that is working well (but i have a lot a data so it’s pretty slow). I want to replace it with the new select2_from_ajax_multiple.
My select2_multiple:
$this->crud->addField([
'label' => "Relance à faire",
'type' => 'select2_multiple',
'name' => 'relances',
'entity' => 'relances',
'attribute' => 'full_name',
'model' => "App\Models\Personne",
'pivot' => true
],'update');
My select2_from_ajax_multiple:
$this->crud->addField([
'label' => "Relance à faire",
'type' => "select2_from_ajax_multiple",
'name' => 'idPersonnes',
'entity' => 'relances',
'attribute' => "full_name",
'model' => "App\Models\Personne",
'data_source' => url("admin/relanceajax"),
'placeholder' => "Selectionner une personne",
'minimum_input_length' => 2,
'pivot' => true
],'update');
It works as i can type in the fields, i have results and i can select many items. But when i save i have this error: BadMethodCallException in Builder.php line 2508: Call to undefined method Illuminate\Database\Query\Builder::idPersonnes()
I’ve try with
'name' => 'relances',
'entity' => 'relances',
But then i have this error: ErrorException in InteractsWithPivotTable.php line 132: Argument 1 passed to Illuminate\Database\Eloquent\Relations\BelongsToMany::formatRecordsList() must be of the type array, string given, called in /home/ubuntu/workspace/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/Concerns/InteractsWithPivotTable.php on line 96 and defined
Also i when open an edit view for a record that already have some data in the pivot table nothing is displayed.
If somebody can give me a clue… Thanks you.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:10 (6 by maintainers)
I am also having a problem just like the one mentioned in this issue.
I have managed to make changes that have resolved most of the bugs with the implementation of the select2_from_ajax_multiple field type.
Before I submit a patch, I would like to know if anyone else has been able to implement with-out changes?
I have updated latest version, its working fine on save. But edit case this is not working. so please change on select2_from_ajax_multiple.blade.php. <select name=“{{ $field[‘name’] }}[]” style=“width: 100%” id=“select2_ajax_multiple_{{ $field[‘name’] }}” @include(‘crud::inc.field_attributes’, [‘default_class’ => ‘form-control’]) multiple>
to
<select name=“{{ $field[‘name’] }}[]” style=“width: 100%” id=“select2_ajax_multiple_{{ $field[‘name’] }}” @include(‘crud::inc.field_attributes’, [‘default_class’ => ‘form-control’]) multiple>
Thanks, Jitender Gurjar.