Skip to content

Commit

Permalink
Better support for array field key/value when either key or value is …
Browse files Browse the repository at this point in the history
…empty (fixes #1972)
  • Loading branch information
w00fz committed Nov 17, 2020
1 parent d63dfc3 commit ed8f24a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Auto-link a plugin/theme license in details if it starts with `http`
* Allow to fallback to `docs:` instead of `readme:`
* Forward a `sid` to GPM when downloading a premium package
* Better support for array field key/value when either key or value is empty [#1972](https://github.com/getgrav/grav-plugin-admin/issues/1972)
1. [](#bugfix)
* Fixed Safari issue with new ACL picker field [#1955](https://github.com/getgrav/grav-plugin-admin/issues/1955)
* Stop propagation of ACL add button in ACL picker [flex-objects#83](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/83)
Expand Down
8 changes: 7 additions & 1 deletion themes/grav/app/forms/fields/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ export default class ArrayField {
let escaped_name = !template.isValueOnly() ? keyElement.val() : this.getIndexFor(element);
escaped_name = escaped_name.toString().replace(/\[/g, '%5B').replace(/]/g, '%5D');
let name = `${template.getName()}[${escaped_name}]`;
valueElement.attr('name', !valueElement.val() ? template.getName() : name);

if (!template.isValueOnly() && (!keyElement.val() && !valueElement.val())) {
valueElement.attr('name', '');
} else {
// valueElement.attr('name', !valueElement.val() ? template.getName() : name);
valueElement.attr('name', name);
}

this.refreshNames(template);
}
Expand Down
Loading

0 comments on commit ed8f24a

Please sign in to comment.