Better support for array field key/value when either key or value is empty (fixes #1972)

This commit is contained in:
Djamil Legato
2020-11-16 20:46:00 -08:00
parent d63dfc3565
commit ed8f24a8e7
3 changed files with 9 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
* Auto-link a plugin/theme license in details if it starts with `http` * Auto-link a plugin/theme license in details if it starts with `http`
* Allow to fallback to `docs:` instead of `readme:` * Allow to fallback to `docs:` instead of `readme:`
* Forward a `sid` to GPM when downloading a premium package * 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) 1. [](#bugfix)
* Fixed Safari issue with new ACL picker field [#1955](https://github.com/getgrav/grav-plugin-admin/issues/1955) * 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) * Stop propagation of ACL add button in ACL picker [flex-objects#83](https://github.com/trilbymedia/grav-plugin-flex-objects/issues/83)

View File

@@ -111,7 +111,13 @@ export default class ArrayField {
let escaped_name = !template.isValueOnly() ? keyElement.val() : this.getIndexFor(element); let escaped_name = !template.isValueOnly() ? keyElement.val() : this.getIndexFor(element);
escaped_name = escaped_name.toString().replace(/\[/g, '%5B').replace(/]/g, '%5D'); escaped_name = escaped_name.toString().replace(/\[/g, '%5B').replace(/]/g, '%5D');
let name = `${template.getName()}[${escaped_name}]`; 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); this.refreshNames(template);
} }

File diff suppressed because one or more lines are too long