Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This is possible by adding an empty section in a form to store this script below. This script will remove form validation if primary key does not exist (which is in add mode).

Thai

ตัวอย่างกรณีการใช้งานนำเสนอเช่นที่การตรวจสอบความถูกต้องของฟอร์มจำเป็นสำหรับการอัปเดตระเบียนเท่านั้นไม่ใช่เพื่อการสร้างบันทึก

สิ่งนี้เป็นไปได้โดยการเพิ่มส่วนที่ว่างในแบบฟอร์มเพื่อเก็บสคริปต์นี้ด้านล่าง สคริปต์นี้จะลบการตรวจสอบแบบฟอร์มหากไม่มีคีย์หลัก (ซึ่งอยู่ในโหมดเพิ่ม)

Code Block
languagejava
linenumberstrue
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);

 


Sample app is available in the link below:

Thai

แอปตัวอย่างมีอยู่ในลิงค์ด้านล่าง:

APP_removeValidation-1-20180502092022.jwa

 


Credits to: panda

 

 

...

Thai

มอบเครดิตให้กับ: แพนด้า