Skip to content

Commit

Permalink
Adds first pass depends field #3529
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed May 1, 2016
1 parent 5816875 commit 313cfe8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/definitions/behaviors/form.js
Expand Up @@ -801,8 +801,11 @@ $.fn.form = function(parameters) {
// takes a validation object and returns whether field passes validation
field: function(field, fieldName) {
var
identifier = field.identifier || fieldName,
$field = module.get.field(identifier),
identifier = field.identifier || fieldName,
$field = module.get.field(identifier),
$dependsField = (field.depends)
? module.get.field(field.depends)
: false,
fieldValid = true,
fieldErrors = []
;
Expand All @@ -818,6 +821,10 @@ $.fn.form = function(parameters) {
module.debug('Field is optional and empty. Skipping', identifier);
fieldValid = true;
}
else if(field.depends && $dependsField.length === 0 || $dependsField.val() === '') {
module.debug('Field depends on another value that is not present or empty. Skipping', $dependsField);
fieldValid = true;
}
else if(field.rules !== undefined) {
$.each(field.rules, function(index, rule) {
if( module.has.field(identifier) && !( module.validate.rule(field, rule) ) ) {
Expand Down

0 comments on commit 313cfe8

Please sign in to comment.