enable Button snippet on visible required fields having values

Inspiration for this idea came from Moshe’s clone snippet. :smiley:

Snippet to evaluate required fields.

skuid.snippet.register('modelReqsMet',function(args) {var params = arguments[0], models = arguments[1], $ = skuid.$, regFields, enableButton = true; // loop through models $.each(models,function(m, model){ regFields = model.registeredFields; $.each(regFields,function(f,field){ if (field.required && !field.row[field.id]) { enableButton = false; } }); }); return enableButton; });

Sample snippet to check one model and set a UI only field of enableNext boolean to true. enableNext = true is used as an Enable Condition on a wizard button in my use case.

skuid.snippet.register('nuAgentReqs',function(args) {var params = arguments[0], $ = skuid.$, modelToUpdate = skuid.$M('nuAgency'), modelToUpdateRow = modelToUpdate.getFirstRow(), modelsToCheck = [skuid.$M('nuAgent')], snip = skuid.snippet.getSnippet('modelReqsMet'); if (snip(arguments[0], modelsToCheck)){ modelToUpdate.updateRow(modelToUpdateRow,{enableNext: true}); } });<br>

Thanks for sharing these Pat.  They are very nice!