Skip to content

Commit 6397554

Browse files
authored
feat(form): set optional field behavior
Adds the possibility to use $('.ui.form').form('set optional', fieldName, bool); to set or unset a field as optional for validation.
1 parent b8551c5 commit 6397554

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/definitions/behaviors/form.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,14 @@ $.fn.form = function(parameters) {
11651165
}
11661166
}
11671167
});
1168+
},
1169+
optional: function(identifier, bool) {
1170+
bool = (bool !== false);
1171+
$.each(validation, function(fieldName, field) {
1172+
if (identifier == fieldName || identifier == field.identifier) {
1173+
field.optional = bool;
1174+
}
1175+
});
11681176
}
11691177
},
11701178

0 commit comments

Comments
 (0)