Skip to content

Commit

Permalink
Add indexes to formData keys
Browse files Browse the repository at this point in the history
  • Loading branch information
KasparRosin committed Sep 6, 2022
1 parent 30bf4a3 commit 0c4a80b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.4] - 06-09-2022

### Changed

- Append array values to formData with index
- Fixes an issue when using alongside other packages that don't respect `data[]` key, but instead want `data[0...n]`

## [1.1.3] - 06-09-2022

### Changed
Expand Down
2 changes: 1 addition & 1 deletion dist/js/entry.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions resources/js/fields/MediaField/FormMediaHubField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ export default {
fill(formData) {
if (this.value && this.value.length) {
this.value.map(mediaItem => {
formData.append(`${this.field.attribute}[]`, mediaItem.id);
this.value.map((mediaItem, index) => {
formData.append(`${this.field.attribute}[${index}]`, mediaItem.id);
});
} else if (this.value && this.value.id) {
formData.append(this.field.attribute, this.value.id);
Expand Down

0 comments on commit 0c4a80b

Please sign in to comment.