Edit Controls Based on Form Definition
A
QueryByExampleSearch form might contain drop down fields, radio buttons and such representing the actual definition of the form. This should be automated. For example, assuming we have a query-by-example form to query features of a certain state, e.g. one control is a drop down list of all
TopicClassifications defined in the
WebForm. Now lets assume that we add an item to the
TopicClassification. The query-by-example form should pick up all items transparently, we do not want to manually update the select tags.
Proposed solution:
Add a
%EDITFORMFIELD{ web="..." topic="..." formfield="AnyFormField" }% variable
-
web: The web where the form definition topic can be found. Default is current web.
-
topic: The topic containing the form definition. Default assumes WebForm.
-
formfield: The form field. HTML input form fields are generated depending on the field type as described in TWikiForms:
-
select - drop-down menu or scrollable box
-
checkbox - one or more checkboxes
-
radio - one or more radio buttons
-
text - a one-line text field
-
textarea - a text box; size is 40x10 (columns x rows)
The variables can be used to build a query-by-example form. For example:
<form name="querybyexample" action="%SCRIPTURLPATH%/search/%WEB%" method="post">
| TopicClassification: | %EDITFORMFIELD{ topic="WebForm" formfield="TopicClassification" }%= |
| ProjectGroup: | %EDITFORMFIELD{ topic="WebForm" formfield="ProjectGroup" }%= |
| ImplementationDate: | %EDITFORMFIELD{ topic="WebForm" formfield="ImplementationDate" }%= |
| Search: | <input type="text" name="string" /> |
| | <input type="submit" /> |
</form>
The hidden field defining how the search is combined into one search is not shown (this is described in
QueryByExampleSearch)
--
PeterThoeny - 12 Jul 2002
Related to this is
FormattedTWikiFormDataInTopicText proposing
%FORMFIELD{"FieldName"}% for pulling form field values from forms.
--
PeterThoeny - 25 Jul 2002
Out of interest, did this go anywhere? If it didn't it strikes me as a useful thing to write... (A use for this came up recently oddly enough - hence the interest in writing it if still viewed as suitable.)
--
MichaelSparks - 18 Aug 2003
This would be a good idea. I'm utterly flummuxed about forms.
--
MartinCleaver - 07 Feb 2004
I think that you can accomplish at least the generation of the options in the select or radio buttons, etc., already using %SEARCH{...}%. You just generate the different options using the query and format it using the format parameter. What that does not do for you is to put the rest of the
HTML around but that is boiler plate (of course, that makes your point, why not abstract it into a variable)?
Note that if you want to do this in the edit for a twiki form (as defined by a table) you probably should apply
PeterKlausner's
patch to switch title and name as what gives the key into the form fields. Extremely handy anyway... as an aside I do not understand why this
patch has not yet been integrated into Core....
--
ThomasWeigert - 07 Feb 2004