Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't you add a EditorExit Handler to a DynamicForm or FormItem?

This handler only exist for a ListGrid.

But if you look at the docs for DynamicForm.setValidateOnExit(), it says:

If true, form items will be validated when each item's "editorExit" handler is fired as well as when the entire form is submitted or validated.

Note that this property can also be set at the item level to enable finer granularity validation in response to user interaction - if true at either level, validation will occur on editorExit.

So how can we add a EditorExitHandler to a DynamicForm or a FormItem?

EDIT :

I want to create an error panel below the form to show all errors dynamically. Each FormITem has the possibility to validate on Exit but I do not know how to capture this validation event to check if the error panel should be updated or not.

like image 268
Adel Boutros Avatar asked Mar 29 '12 10:03

Adel Boutros


1 Answers

There is one method form.getErrors() and form.showError(true). By this you can acheive that. But for that also you need to setValidator for each field.

TextItem name = new TextItem("name", "Name");
name.setRequired(true);
name.setRequiredMessage("Please specify name of the Table");

NTRegExpValidator nameValidator = new NTRegExpValidator("(^[a-zA-Z0-9][\\w\\s.()_-]+)$","It should start with alphabets and can have alphanumeric values ( )_-. and space.");

name.setValidators(nameValidator);
name.addKeyUpFieldHandler(new KeyUpHandler){
    form.getErrors();
    form.showErrror(true);
});

DynamicForm form = new DynamicForm();
form.setField(name);
like image 197
PVR Avatar answered Oct 15 '22 09:10

PVR