【问题标题】:Laravel Backpack select2_from_ajax pass multiple or extra search keyword for searchLaravel Backpack select2_from_ajax 传递多个或额外的搜索关键字进行搜索
【发布时间】:2020-12-23 16:54:56
【问题描述】:

当前 select2_from_ajax 仅通过搜索 q 搜索词。如何将多个搜索信息传递给该方法?

我需要传递当前记录 ID /admin/product/4。

我需要按 product_id 4 和关键字进行 sql 过滤。我该怎么做?

CRUD::field('select2_from_ajax')
                ->type('select2_from_ajax')
                ->label("Article <small class='font-light'>(select2_from_ajax for a 1-n relationship)</small>")
                ->entity('article')
                ->attribute('title')
                ->model('Backpack\NewsCRUD\app\Models\Article')
                ->data_source(url('api/article'))
                ->placeholder('Select an article')
                ->minimum_input_length(2)
                ->wrapper(['class' => 'form-group col-md-6'])
                ->tab('Selects');

【问题讨论】:

    标签: laravel laravel-backpack


    【解决方案1】:

    为了传递所有表单值,只需添加-&gt;include_all_form_fields(true)。

    完整的字段定义如下:

    CRUD::field('select2_from_ajax')
                    ->type('select2_from_ajax')
                    ->label("Article <small class='font-light'>(select2_from_ajax for a 1-n relationship)</small>")
                    ->entity('article')
                    ->attribute('title')
                    ->model('Backpack\NewsCRUD\app\Models\Article')
                    ->data_source(url('api/article'))
                    ->placeholder('Select an article')
                    ->minimum_input_length(2)
                    ->wrapper(['class' => 'form-group col-md-6'])
                    ->tab('Selects')
                    ->include_all_form_fields(true);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多