Tuesday, June 12, 2007

Simplifying maintenance of multiple similar fields

I bet most developers have made forms with several fields that are identical apart from their names. This method aims to simplify some of the maintenance on such forms, for Notes/Domino developers.

First, create a "computed for display" text-field.
This will be the datasource/contain some javascript/css/style (I know.. mixing data, behaviour and design, all bad stuff, but this is just an example).

Default value:

choices:="Norway|no;Sweden|se;Denmark|dk;United Kingdom|uk";
defaultvalue:="se";
htmlattrs:="onclick=\"alert(this.value)\" style=\"color:red\" class=\"country\"";

choices:defaultvalue:htmlattrs;

choices could also be a dblookup/dbcolumn. Remember to implode it, to allow for a fixed number of settings. Example: @Implode(@DbColumn("";"";"view";2);";").

If you have multiple similar non-multivalue fields, you'd probably just need html attributes, and maybe default value. Seeing as multi-value fields often have more settings, I'll focus on these.

Field properties -> Choices ("Use formula for choices"): @Explode(srcCountries[1];";")

Default value: srcCountries[2]

HTML Attributes: srcCountries[3]


Screenshots:


In the designer




In the client (border-style=none set manually before copy/paste)




On the web




Onlick (from the htmlattrs in the computed for display field)



REMEMBER! Describe the cfd-field containing the settings, so that you understand it the next time you're working on the form..

0 comments: