How to set validation on same field at later stage in subform

Confluence User - 02 May, 2018

I have a very long form which contains fields without mandatory validation on 1st instance of form (1st submission). On review of the same form, those same field Id’s have to be set to mandatory. How can I go about this as I don’t want to have to create two versions of the same form solely for this purpose. Thanks.

form

1


02 May, 2018
confluenceUser
confluenceUser

Hi, it seems possible by adding an empty section with load binder. I using the script below. This will remove validator when the primary key is empty which is in add mode.

import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.service.FormUtil;
import org.joget.apps.form.model.Element;
import org.joget.apps.form.model.Form;
import org.joget.apps.form.model.FormData;
import org.joget.apps.form.model.FormRowSet;
public FormRowSet load(Element element, String primaryKey, FormData formData) {
    if (primaryKey == null) {
        Form form = FormUtil.findRootForm(element);
        removeValidator(form, formData);
    }
    return null;
}
public void removeValidator(Element e, FormData formData) {
    e.setValidator(null);
    
    Collection children = e.getChildren(formData);
    if (children != null) {
        for (Element child : children) {
            removeValidator(child, formData);
        }
    }
}
//call load method with injected variable
return load(element, primaryKey, formData);

 

This is my test app using v6.

APP_removeValidation-1-20180502092022.jwa

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print