Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Form Validation in Multi-Dialog  (Read 8965 times)
Tim B.
Posts: 67


« 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
  1.        BEFORE INPUT
  2.            IF ma_contracts.getLength() = 0 THEN
  3.                    NEXT FIELD scr_con.contract_id   #in 'parent' dialog
  4.            END IF
  5.  
Sebastien F.
Four Js
Posts: 509


« Reply #1 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
Tim B.
Posts: 67


« Reply #2 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)
Sebastien F.
Four Js
Posts: 509


« Reply #3 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
Bryce S.
Posts: 52


« Reply #4 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
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines