Open Shahjalal7311 opened 1 year ago
add ->config('maximumSelectionLength', 1);
$form->multipleSelect('roles', trans('admin.roles'))->options($roleModel::all()->pluck('name', 'id'))->config('maximumSelectionLength', 1);
@Yanghsuanming thank you!
I also fix cascade linking issue adding a belongsToMany relation i.e.
`public function adminRole() { return $this->belongsToMany(AdminRole::class, 'admin_role_users', 'user_id', 'role_id');
}`
Above and your suggested method i.e. ->config('maximumSelectionLength', 1); works well in CREATE/Adding but unfortunately when EDIT it produce error:
ViewException In CanCascadeFields.php line 163 : addslashes(): Argument #1 ($string) must be of type string, array given (View: /vendor/encore/laravel-admin/resources/views/form.blade.php)
on line 163, that function is defined ` /**
i debug and found that $this->value() return array
array:1 [▼ // vendor/encore/laravel-admin/src/Form/Field/CanCascadeFields.php:163 0 => 5 ]
If i modify and return
$value=$this->value(); return addslashes(old($this->column(), $this->$value[0]));//i.e. 5
it works, but i donot want to change core file.
Any help please!
Description:
I am trying to remove multiselect and add only select in Usercontroller. But it's not working.The error is
Array to string conversion (View: project/encore/laravel-admin/resources/views/form.blade.php)
Steps To Reproduce:
What's i am doing wrong. Any one can help me to find the solution.