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: Highlighting required fields.  (Read 15503 times)
David H.
Posts: 158


« on: May 03, 2013, 01:43:08 pm »

I wanted to create a little function to highlight all 'REQUIRED' fields on all screens. My first attempt was a partial success but fails on CheckBox fields.  The code I wrote queried the AUI for FormFields with the attribute of required=1. I notice that for a CheckBox defined as:-

Code
  1. CHECKBOX   eb = sale_in_bond ,VALUECHECKED="Y", VALUEUNCHECKED="N", NOT NULL, TEXT = " ";
  2.  

required=1, whereas logically I would have expected this to only be the case if it was defined as:-

Code
  1. CHECKBOX   eb = sale_in_bond ,VALUECHECKED="Y", VALUEUNCHECKED="N", NOT NULL, TEXT = " ", REQUIRED;
  2.  

So its looking like the way I was attempting to do this is not going to work. Hopefully someone can suggest a better way to achieve what I'm after...

Reuben B.
Four Js
Posts: 1126


« Reply #1 on: May 06, 2013, 11:37:40 pm »

Hi David,

I don't know if you participated in the 2.41 EAP but attempts were made to do something similar, and display an asterix to the right of mandatory fields.  I don't know the exact reasons it was abandoned but there were many different ways users wanted to show mandatory, asterix to the right, asterix to the left, different colour background, different colour border etc.  , In the GWC if you still want to do this, it is case of adding a few lines to the .css file doing what you want to show the mandatory.

What also came out of that, was how do you define a mandatory field?  For some it was if REQUIRED was set, for others it was if NOT NULL was set.

However there was one other thing that was observed.  If you define NOT NULL, then when the form was compiled, it would also set REQUIRED e.g.  So with this .per, note how in the resultant .42f the field with name not null also has required="1"

Code
  1. SCREEN
  2. {
  3. [f01  ]
  4. [f02  ]
  5. [f03  ]
  6. [f04  ]
  7. }
  8. END
  9. ATTRIBUTES
  10. f01 = formonly.blank;
  11. f02 = formonly.required, REQUIRED;
  12. f03 = formonly.notnull, NOT NULL;
  13. f04 = formonly.both, REQUIRED, NOT NULL;

Code
  1. <?xml version='1.0' encoding='windows-1252'?>
  2. <Form name="formcompile" build="2.50.00-2239" width="7" height="4">
  3.  <Screen width="7" height="4">
  4.    <FormField name="formonly.blank" colName="blank" fieldId="0" sqlTabName="formonly" tabIndex="1">
  5.      <Edit width="5" posY="0" posX="1" gridWidth="5"/>
  6.    </FormField>
  7.    <FormField name="formonly.required" colName="required" fieldId="1" sqlTabName="formonly" required="1" tabIndex="2">
  8.      <Edit width="5" posY="1" posX="1" gridWidth="5"/>
  9.    </FormField>
  10.    <FormField name="formonly.notnull" colName="notnull" fieldId="2" sqlTabName="formonly" notNull="1" required="1" tabIndex="3">
  11.      <Edit width="5" posY="2" posX="1" gridWidth="5"/>
  12.    </FormField>
  13.    <FormField name="formonly.both" colName="both" fieldId="3" sqlTabName="formonly" required="1" notNull="1" tabIndex="4">
  14.      <Edit width="5" posY="3" posX="1" gridWidth="5"/>
  15.    </FormField>
  16.  </Screen>
  17.  <RecordView tabName="formonly">
  18.    <Link colName="blank" fieldIdRef="0"/>
  19.    <Link colName="required" fieldIdRef="1"/>
  20.    <Link colName="notnull" fieldIdRef="2"/>
  21.    <Link colName="both" fieldIdRef="3"/>
  22.  </RecordView>
  23. </Form>

I also came across this when importing .per files into Studio to turn them into .4fd.  A field that is defined as NOT NULL will end up with the Not Null and Required properties checked, this is because to do the import, Studio compiles the form to produce a .42f and then produces a .4fd from that.

Like you when I first saw this above behaviour I thought it was wrong, IMHO NOT NULL should set the notNull attribute, REQUIRED should set the required attribute, but this behaviour of not null setting the required attribute in the .42f has always been there.

To answer your question, are you sure you want to be testing the required attribute?  It is possible to enter a blank or space into a field and satisfy the required attribute, IMHO the better test is to query the AUI for FormFields with the attribute of notnull = "1"


Reuben


Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Nuno G.
Posts: 38


« Reply #2 on: May 13, 2013, 05:14:53 pm »

Please take a look at the attached example.
HIH
Best regards
Nuno

* highlight.tar (30 KB - downloaded 1015 times.)
Reuben B.
Four Js
Posts: 1126


« Reply #3 on: May 13, 2013, 10:26:21 pm »

Hi Nuno,

Are you aware of sourcefourjs https://code.google.com/p/sourcefourjs/ ?

Feel free to add your example to the Downloads section on that site.

I have an example up there named auitree that shows lots of similar technique of AUI Tree manipulation but I didn't have an example that shows adding a LABEL like you have done.

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Nuno G.
Posts: 38


« Reply #4 on: May 14, 2013, 10:19:51 am »

Thank you Reuben. I'll glady share it.
Best regards
Nuno
Nuno G.
Posts: 38


« Reply #5 on: May 14, 2013, 10:30:05 am »

Hi Reuben!
I took a look but I can figure out how to upload the example.
Maybe you could give a hint ?
Best regards
Nuno
Reuben B.
Four Js
Posts: 1126


« Reply #6 on: May 15, 2013, 11:09:43 pm »

Hi,

Once you have signed in, under Download, there is a button "New Download"

Reuben

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Jeff M.
Posts: 40


« Reply #7 on: June 09, 2013, 04:43:15 pm »

Would it not be possible to have a pseudo selector in styles, .required? Obviously combo boxes would need to work consistently. Perhaps a .notnull selector too?
Sebastien F.
Four Js
Posts: 545


« Reply #8 on: June 10, 2013, 09:29:37 am »

I agree that in a programming language like Genero, there should be a built-in solution do render mandatory fields in a different way. Programmers should not have to write special code for this... Return to simplicity.

A request was filed end 2012 for this, as bz#23309.

Since there is non-trivial logic behind NOT NULL / REQUIRED attributes, so far the idea is to have a unique pseudo-selector for both attributes ("mandatory"), but maybe we better distinguish both attributes...

Seb
David H.
Posts: 158


« Reply #9 on: June 13, 2013, 11:35:35 am »

Sounds good Seb, hope to see this one day soon...!
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines