Skip to content

Commit d794dbe

Browse files
authored
Merge pull request #23 from PrintNow/fix/form-duplicate-params
fix: 修复表单提交参数重复问题 (#22)
2 parents bea3fb1 + af0d4db commit d794dbe

4 files changed

Lines changed: 40 additions & 4 deletions

File tree

.jshintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
resources/dist/
3+
resources/assets/dcat/plugins/
4+
resources/assets/adminlte/
5+
vendor/

.jshintrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"esversion": 11,
3+
"browser": true,
4+
"module": true,
5+
"jquery": true,
6+
"undef": true,
7+
"unused": true,
8+
"eqeqeq": true,
9+
"curly": true,
10+
"strict": false,
11+
"globals": {
12+
"Dcat": true,
13+
"NProgress": true,
14+
"Swal": true,
15+
"toastr": true,
16+
"axios": true,
17+
"moment": true,
18+
"Pjax": true,
19+
"layui": true,
20+
"tinymce": true,
21+
"SimpleMDE": true,
22+
"marked": true,
23+
"UE": true,
24+
"wangEditor": true,
25+
"HtmlEditor": true
26+
}
27+
}

resources/views/form/multipleselect.blade.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@
1313
<option value="{{ $select }}" {{ in_array($select, (array) $value) ?'selected':'' }}>{{$option}}</option>
1414
@endforeach
1515
</select>
16-
<input type="hidden" name="{{$name}}[]" />
16+
<input type="hidden" name="{{$name}}[]" {!! $value ? 'disabled' : '' !!}/>
1717

1818
@include('admin::form.help-block')
1919

2020
</div>
2121
</div>
2222

2323
@include('admin::form.select-script')
24+
25+
<script>
26+
$('.{{$selector}}').off('change.select2').on('change.select2', function () {
27+
$(this).closest('.field').find('input[type="hidden"][name="{{$name}}[]"]').prop('disabled', $(this).val()?.length > 0);
28+
});
29+
</script>

src/Form/Builder.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,9 +722,7 @@ public function render()
722722
);
723723
}
724724

725-
$content = $this->layout->build(
726-
$this->renderHiddenFields()
727-
);
725+
$content = $this->layout->build();
728726
}
729727

730728
return "{$open}{$content}{$this->close()}";

0 commit comments

Comments
 (0)