如何在Backpack laravel中保存select2_from_ajax_multiple中的多个值

时间:2021-03-12 06:30:44

标签: php laravel backpack-for-laravel laravel-backpack

大家

我想从 select 选项中保存多个值,但我不知道如何在 Laravel Backpack 中保存。我从 2 天起一直在尝试解决错误,但是仍然在我这边不起作用。

请看看,帮助将不胜感激。
这是多选选项的屏幕截图 --- enter image description here

但它没有保存在数据库中,但是如果我要编辑记录,则会出现此错误 --- enter image description here

这是我的控制器代码

CRUD::addField([ // select2_from_ajax: 1-n relationship
      'label'                => "City Name", // Table column heading
      'type'                 => 'select2_from_ajax_multiple',
      'name'                 => 'location_id', // the column that contains the ID of that connected entity;
      'entity'               => 'location', // the method that defines the relationship in your Model
      'attribute'            => 'name', // foreign key attribute that is shown to user
      'tab'                  => 'Texts',
      'data_source'          => url('api/location'), // url to controller search function (with /{id} should return model)
      'placeholder'          => 'Select location', // placeholder for the select
      'include_all_form_fields' => true, //sends the other form fields along with the request so it can be filtered.
         'minimum_input_length' => 0, // minimum characters to type before querying results
      'dependencies'         => ['state'], // when a dependency changes, this select2 is reset to null
      // 'method'                    => 'GET', // optional - HTTP method to use for the AJAX call (GET, POST)
      "allows_multiple" => true,
      'pivot' => true,
]);

0 个答案:

没有答案
相关问题