Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix/multi option name #274

Merged
merged 2 commits into from
Oct 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .fontello
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b27e9f4df1193078015631ab448fad05
b46a79f8f5e9e5a1a9d80ee4b3db9689
12 changes: 9 additions & 3 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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())
Expand All @@ -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())
Expand Down
12 changes: 8 additions & 4 deletions src/js/form-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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]);
Expand All @@ -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>`;
Expand All @@ -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;" />`;
}

}
Expand Down