From a4faef34fe41bf0a0d4141061db8fb4715a2d0b9 Mon Sep 17 00:00:00 2001 From: Ayush Gupta Date: Thu, 11 Aug 2016 15:18:53 -0400 Subject: [PATCH] :bug: skip required checkbox; validation setting --- lib/form/html.js | 2 +- lib/form/validate.js | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/form/html.js b/lib/form/html.js index 92c23b6..bd0e214 100644 --- a/lib/form/html.js +++ b/lib/form/html.js @@ -84,7 +84,7 @@ const addRequired = (html, input, index) => { inputs.map(inp => { // Skip the required attribute for checkbox and radio on browser - if (input.type === 'checkbox' || input.type === 'radio') { + if (inp.type === 'checkbox' || inp.type === 'radio') { return; } diff --git a/lib/form/validate.js b/lib/form/validate.js index 722108d..e622f56 100644 --- a/lib/form/validate.js +++ b/lib/form/validate.js @@ -108,10 +108,19 @@ const buildSettings = type => { const settings = {}; type.attributes.map(plugin => { + let input = {}; settings[plugin.id] = {}; - return Object.keys(plugin.inputs).map(input => { - settings[plugin.id][input] = plugin.inputs[input].settings; + // If multiple instances take the first one for settings + if (Array.isArray(plugin.inputs)) { + input = plugin.inputs[0]; + } + else { + input = plugin.inputs; + } + + return Object.keys(input).map(inp => { + settings[plugin.id][inp] = input[inp].settings; }); }); @@ -272,7 +281,7 @@ const validate = (raw, type, check) => { input.target.required = plugin.required; } - // If mutilple instances use the first instance + // If multiple instances use the first instance if (Array.isArray(plugin.inputs)) { if (plugin.inputs[0][result.input].hasOwnProperty('required')) { input.target.required = plugin.inputs[0][result.input].required;