以官方Demo为例:
DataForm页面
去掉所有的复选框, 点击 Save 按钮
重新打开DataForm页面, 数据并没有改变, 这是bug
若至少保留其中一项, 则结果会改变
修改文件:
vendor/zofe/rapyd/src/DataForm/Field/Field.php
修改前:
public function updateRelations() {
.....
case 'Illuminate\Database\Eloquent\Relations\BelongsToMany':
$old_data = $this->relation->get()->modelKeys();
$new_data = explode($this->serialization_sep, $data);
$this->relation->detach($old_data);
if ($data=='') {
continue;
}
.....
修改后:
public function updateRelations() {
case 'Illuminate\Database\Eloquent\Relations\BelongsToMany':
.....
$old_data = $this->relation->get()->modelKeys();
// $data 改成 $this->new_value
$new_data = explode($this->serialization_sep, $this->new_value);
$this->relation->detach($old_data);
//判断条件修改
if (empty($this->new_value)) {
break;
}
......