laravel-admin弹出表单select组件无法使用ajax搜索

  • Laravel Version: 6.2
  • PHP Version: 7.2
  • Laravel-admin: 1.7
$this->select('shop_id', __('wbq.shop_name'))->options(function ($id) {
            $shop= Shop::find($id);
            if ($shop) {
                return [$shop->id => $shop->shop_name];
            }
        })->ajax('/api/shops')

在Form表单中是正常的,$form->select...

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 3

我也是这个问题

3年前 评论

加ajax不就行了,之前一直没注意

3年前 评论

Laravel Version: 5.7

PHP Version: 7.2

Laravel-admin: 1.8

        $form->select('customer_id','企业名称')->options(function ($id) {

            $customer = Customer::find($id);

            if ($customer) {

                return [$customer->id => $customer->name];

            }

        })->ajax('/admin/customers/search');

ajax的链接返回的是

file

ajax链接对应的代码

public function search(Request $request){

    $q = $request['q'];

    return Customer::where('name','like',"%{$q}%")->paginate(null,['id','name']);

}

实际页面显示

file

@西部荒野 你是这个原因吗

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!