Skip to content

Commit

Permalink
feat(form): set optional field behavior
Browse files Browse the repository at this point in the history
Adds the possibility to use $('.ui.form').form('set optional', fieldName, bool); to set or unset a field as optional for validation.
  • Loading branch information
Giandrop authored Oct 11, 2020
1 parent b8551c5 commit 6397554
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/definitions/behaviors/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,14 @@ $.fn.form = function(parameters) {
}
}
});
},
optional: function(identifier, bool) {
bool = (bool !== false);
$.each(validation, function(fieldName, field) {
if (identifier == fieldName || identifier == field.identifier) {
field.optional = bool;
}
});
}
},

Expand Down

0 comments on commit 6397554

Please sign in to comment.