Title: Highlighting required fields. Post by: David H. 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
required=1, whereas logically I would have expected this to only be the case if it was defined as:- Code
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... Title: Re: Highlighting required fields. Post by: Reuben B. 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
Code
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 Title: Re: Highlighting required fields. Post by: Nuno G. on May 13, 2013, 05:14:53 pm Please take a look at the attached example.
HIH Best regards Nuno Title: Re: Highlighting required fields. Post by: Reuben B. 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 Title: Re: Highlighting required fields. Post by: Nuno G. on May 14, 2013, 10:19:51 am Thank you Reuben. I'll glady share it.
Best regards Nuno Title: Re: Highlighting required fields. Post by: Nuno G. 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 Title: Re: Highlighting required fields. Post by: Reuben B. on May 15, 2013, 11:09:43 pm Hi,
Once you have signed in, under Download, there is a button "New Download" Reuben Title: Re: Highlighting required fields. Post by: Jeff M. 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?
Title: Re: Highlighting required fields. Post by: Sebastien F. 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 Title: Re: Highlighting required fields. Post by: David H. on June 13, 2013, 11:35:35 am Sounds good Seb, hope to see this one day soon...!
|