Permalink
Browse files

Hotfix/multi option name (#274)

* Bugfix: gulp font-edit on windows

* Bugfix: option name attribute for multi select files, select and input fields
  • Loading branch information...
1 parent 2f50438 commit 12ab3c36143233997d49deb7486f4a7afde80e98 @kevinchappell committed on GitHub Oct 7, 2016
Showing with 18 additions and 8 deletions.
  1. +1 −1 .fontello
  2. +9 −3 gulpfile.babel.js
  3. +8 −4 src/js/form-render.js
View
@@ -1 +1 @@
-b27e9f4df1193078015631ab448fad05
+b46a79f8f5e9e5a1a9d80ee4b3db9689
View
@@ -156,7 +156,9 @@ gulp.task('js', function() {
return jsFiles.forEach(function(jsFileGlob, key) {
// Demo scripts minified
gulp.src(jsFileGlob)
- .pipe(plugins.plumber({ errorHandler: false }))
+ .pipe(plugins.plumber({
+ errorHandler: false
+ }))
.pipe(plugins.babel())
.pipe(plugins.concat(rename(key) + '.min.js'))
.pipe(plugins.uglify())
@@ -165,7 +167,9 @@ gulp.task('js', function() {
// Plugin scripts
return gulp.src(jsFileGlob)
- .pipe(plugins.plumber({ errorHandler: false }))
+ .pipe(plugins.plumber({
+ errorHandler: false
+ }))
.pipe(plugins.babel())
.pipe(plugins.concat(rename(key) + '.js'))
.pipe(banner())
@@ -192,7 +196,9 @@ gulp.task('devJS', function() {
// Demo scripts minified
return gulp.src(jsFileGlob)
.pipe(plugins.plumber())
- .pipe(plugins.sourcemaps.init({ loadMaps: true }))
+ .pipe(plugins.sourcemaps.init({
+ loadMaps: true
+ }))
.pipe(plugins.babel())
.pipe(plugins.concat(rename(key) + '.min.js'))
.pipe(plugins.uglify())
View
@@ -60,7 +60,9 @@ function FormRenderFn(options, element) {
fieldDesc = fieldData.description || '',
fieldRequired = '',
fieldOptions = fieldData.values || [];
+
fieldData.id = fieldData.name;
+ fieldData.name = fieldData.multiple ? fieldData.name + '[]' : fieldData.name;
fieldData.type = fieldData.subtype || fieldData.type;
@@ -112,9 +114,12 @@ function FormRenderFn(options, element) {
let optionAttrs;
fieldData.type = fieldData.type.replace('-group', '');
+ if (fieldData.type === 'checkbox') {
+ fieldData.name = fieldData.name + '[]';
+ }
+
if (fieldOptions) {
- let optionName = fieldData.type === 'checkbox' ? fieldData.name + '[]' : fieldData.name,
- optionAttrsString;
+ let optionAttrsString;
for (let i = 0; i < fieldOptions.length; i++) {
optionAttrs = Object.assign({}, fieldData, fieldOptions[i]);
@@ -124,7 +129,6 @@ function FormRenderFn(options, element) {
optionAttrs.checked = null;
}
- optionAttrs.name = optionName;
optionAttrs.id = fieldData.id + '-' + i;
optionAttrsString = utils.attrString(optionAttrs);
optionsMarkup += `<input ${optionAttrsString} /> <label for="${optionAttrs.id}">${optionAttrs.label}</label><br>`;
@@ -138,7 +142,7 @@ function FormRenderFn(options, element) {
optionAttrsString = utils.attrString(Object.assign({}, fieldData, otherOptionAttrs));
- optionsMarkup += `<input ${optionAttrsString} /> <label for="${otherOptionAttrs.id}">${opts.label.other}</label> <input type="text" data-other-id="${otherOptionAttrs.id}" name="${optionName}" id="${otherOptionAttrs.id}-value" style="display:none;" />`;
+ optionsMarkup += `<input ${optionAttrsString} /> <label for="${otherOptionAttrs.id}">${opts.label.other}</label> <input type="text" data-other-id="${otherOptionAttrs.id}" name="${otherOptionAttrs.name}" id="${otherOptionAttrs.id}-value" style="display:none;" />`;
}
}

0 comments on commit 12ab3c3

Please sign in to comment.