Title: Form Validation in Multi-Dialog Post by: Tim B. on February 04, 2010, 10:21:38 am I've got a large multi-dialog with various master-detail levels in it. Obviously I need to prevent someone entering a detail level if it has not yet got a parent record, so I have a BEFORE INPUT which checks if a parent exists, and if not, does a NEXT FIELD to the master record.
The problem is I'm being caught out by the form validation 'This field requires an entered value'. This is the documented behaviour (https://4js.com/online_documentation/fjs-fgl-2.21.01-manual-html/User/MultipleDialogs.html#form-level-validation), but somehow I need to get round this so I can make sure things get created in the correct order. Is there any way around this? Code
Title: Re: Form Validation in Multi-Dialog Post by: Sebastien F. on February 04, 2010, 04:05:20 pm I would try to disable the fields that are not to be used until the master information is complete and valid.
I would typically do field activation/deactivation in a "dialog setup" function to centralize field and action activation according to the context... FUNCTION dialog_setup(d) DEFINE d ui.Dialog LET master_complete = check_master_info() CALL d.setFieldActive("detail_field1", master_complete) CALL d.setFieldActive("detail_field1", master_complete) CALL d.setFieldActive("detail_field1", master_complete) CALL d.setActionActive("detail_new", master_complete) CALL d.setActionActive("detail_delete", master_complete) CALL d.setActionActive("detail_save", master_complete) .... You can see such programming pattern in FGLDIR/demo/MultipleDialogs. demo/Tools shows also some quite complex dialogs using this technique. Seb Title: Re: Form Validation in Multi-Dialog Post by: Tim B. on February 04, 2010, 04:28:57 pm After looking at this for most of the day, this is the conclusion I have also come to, except that I have used a function to disable all the FormFields with a page using some DomNode functions. It's a bit extreme but it works. The problem is now getting it activated & deactivated in all the right places (I have about 10 dialogs and several master/detail levels :( )
If this were an INPUT ARRAY, I wouldn't have to do this, since it would have created a temporary row, and the form validation wouldn't have fired. It would be nice to be able to leave an INPUT dialog without this happening, specifically for situations like this. I notice there is a VALIDATE option for ACTIONs, which I think does this, but I wasn't able to use this in this instance. Incidentally, I tried to disable fields using:- CALL l_node2.setAttribute("active",0) but this had no effect and I had to use this instead:- CALL l_dialog.setFieldActive(l_node2.getAttribute("colName"),0) Title: Re: Form Validation in Multi-Dialog Post by: Sebastien F. on February 04, 2010, 04:58:45 pm Tim,
Yes you should not disable FormFields with the OM API: https://4js.com/techdocs/genero/fgl/devel/DocRoot/User/Mig0001.html#ActionAndFieldActivation The 'active' attribute is reset by the dialog according to an internal flag. Seb Title: Re: Form Validation in Multi-Dialog Post by: Bryce S. on February 04, 2010, 10:34:46 pm The problem is I'm being caught out by the form validation 'This field requires an entered value'. This is the documented behaviour (https://4js.com/online_documentation/fjs-fgl-2.21.01-manual-html/User/MultipleDialogs.html#form-level-validation), but somehow I need to get round this so I can make sure things get created in the correct order. Is there any way around this? Hi Tim, I've been caught out by this more than once. I found the simplest solution in my situation was to turn off form validation (by removing not null, required, etc) and instead do validation on after field and/or after input. I guess if your form has each input called from many different input statements this may not be so practical... Regards, Bryce Stenberg |