Skip to content

Commit

Permalink
Merge pull request #89 from ayush2k/bugfix/validation
Browse files Browse the repository at this point in the history
skip required checkbox; validation setting
  • Loading branch information
Snugug committed Aug 11, 2016
2 parents dce4d7d + a4faef3 commit 61fc6a3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/form/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
15 changes: 12 additions & 3 deletions lib/form/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 61fc6a3

Please sign in to comment.