This question about Missing functionality: Answered but needs rewriting

Hiding of empty formfields in topics

Hey folks!

I have data form which I use to specify chemical characteristics of raw materials. Not every type of raw materials necessarily needs all formfields which are provided by the data form. So from 25 fields 5 are mandatory for all raw materials and the rest is depending if its a solvent or a resin or powder or whatever.

So here are my questions:

1. Is there any chance to hide empty formfields in the topic view but enabling to see them in editing mode?

2. Or maybe hide them due to the state of a formfield at the beginning of the dataform? So that a solvent have some kind of fields and if I choose resin this would have other formfields. Don't want to create several dataforms for reasons of complexity.

Any help or comment highly appreciated.

The basic part is using the FORMFIELD macro (System.Macros). You then group the fields as you best can. But then you need to consider having the text and layout in each topic, like from a template when created. That can be much work if all are to be updated with a new formfield or something later. Or....

A more flexible and better solution is to use some of the excellent functionality of templates (VIEW_TEMPLATE), INCLUDE and more. Though it takes some effort to get the grips, it is very worth it.

Example, use sectional INCLUDE, like in Support.Faq22.

FlexFormPlugin is suitable. I havent tried it out yet but it lets you render those formfields you want and customize. Also for editing.

I would use the AutoViewTemplatePlugin. Then you create one topic which is the view "overlay" for all topics with the 'ChemicalForm', for all those topics you make the layout in the view template. I created a new page, called it 'ChemicalViewTemplate'. It then matches all topics having the form 'ChemicalForm'. In the text of that ChemicalViewTemplate I put:
%TMPL:INCLUDE{"view"}% 
%TMPL:DEF{"form"}%%TMPL:END% 
%TMPL:DEF{"content"}%

...here you layout whatever..like %FORMFIELD{"Type" default="not set" alttext="update topic, this is a new field"}%

..use %BASETOPIC% instead of %TOPIC%...

...use %INCLUDE..include sections.. With this you can group formfields into groups in different sections (in a html comment or a separate topic). 
...You then INCLUDE them here and then you have them at the same place on the page, so the layout is better.

...to look up values and link via a formfield in another topic by reference from a topic saved in this topic's form:
  %FORMFIELD{"Vendor" default="%BASETOPIC%" alttext="%BASETOPIC%"}%][%FORMFIELD{"Name" topic="%FORMFIELD{Vendor}%"  }%]]

...You can have SEARCH in here also...

%TMPL:END%

-- LarsEik - 25 Mar 2010

QuestionForm edit

Subject Missing functionality
Extension
Version Foswiki 1.0.9
Status Answered but needs rewriting
Topic revision: r2 - 25 Mar 2010, LarsEik
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy