Clean up POST keys containing square brackets, allows for regex ranges in routes (fixes #776)

This commit is contained in:
Djamil Legato
2016-09-15 12:57:28 -07:00
parent 0512a7f4f6
commit aba43374de
5 changed files with 39 additions and 16 deletions

View File

@@ -96,7 +96,9 @@ export default class ArrayField {
let keyElement = type === 'key' ? element : element.siblings('[data-grav-array-type="key"]:first');
let valueElement = type === 'value' ? element : element.siblings('[data-grav-array-type="value"]:first');
let name = `${template.getName()}[${!template.isValueOnly() ? keyElement.val() : this.getIndexFor(element)}]`;
let escaped_name = !template.isValueOnly() ? keyElement.val() : this.getIndexFor(element);
escaped_name = escaped_name.replace(/\[/g, '%5B').replace(/]/g, '%5D');
let name = `${template.getName()}[${escaped_name}]`;
valueElement.attr('name', !valueElement.val() ? template.getName() : name);
this.refreshNames(template);