FormLayout submit fields ?

I’ve a FormLayout in my project, in this FormLayout I’ve one field email that I use EmailValidator to validate and one Button(“Save”).

When I enter with email on field email the validate is work and mark the field with (!) red if there any error.

How to I can check formlayout when I click on Button(“Save”) if there any field with validate error(!) the formlayout not be submited ?

Any idea ?

thanks

Hi,

if you just have a FormLayout, you need to validate the fields manually. Something like this:

public void onSave() {
 for (Field f : referencesToYourFields) {
  try {
   f.validate();
  } catch (InvalidValueException e) {
   // show error message etc.
   return;
  }
 }
 // Do the actual submit
}

If you would use either Form or FieldGroup with your fields, you can get this functionality done automatically by the framework.