Question
I tried scouring the other support topics on forms but was unable to find an exact answer on how to do this. ( Then again, I can never find the ketchup in the fridge, so.. )
I've created a simple form to allow the 'approval' of documents, basically giving each document a status. The only part I'm having trouble with is that I have a field for 'approved by'.
I'd like to make this field a text field that defaults to the TWiki username of the user submitting the form. I'd also like to disable the field so that it cannot be changed.
I tried to edit the
WebTopicEditTemplate for the web and I inserted % WIKIUSERNAME% into the default value.
This runs into two issues though. When I add the form to an existing topic, it does not come up at all. No text is entered into the field. The second is that when I create a new topic, instead of the actual username, it brings up % WIKIUSERNAME%. This would be fine if it actually stored the username, but it actually stores % WIKIUSERNAME% as the value, and whenever someone views the page, it looks as if they were the ones who approved it.
I also could not find anything on disabling a form field.
Any help would be appreciated.
Environment
--
StevenHajducko - 02 Jun 2005
Answer
Other useful topics concerning stuff like this are
HandleCommonTagsInFormDef,
FormValuesFromSearch,
TWikiFormsDontExpandVariables. However, none of them are explaining it well enough for my neophyte self.
--
StevenHajducko - 02 Jun 2005
Is there anyway to use the
WebTopicEditTemplate as an override for some form values, but not all?
In other words, if using the
FormsAddOn, if you create a form with default values in the form definition, and then specify the form in the edit template, how can you make it so that certain form values are overwritten and some aren't? At the moment, blank values in the
WebTopicEditTemplate override values specified in the form definition.
--
StevenHajducko - 03 Jun 2005
You should be able to create a
TWikiForms with an "Approval" field of type "label" and attach that to your
WebTopicEditTemplate.
You
should be able to initialize the field with
%WIKIUSERNAME% although I have not tried that. Alternatively, use an HTML form to create a new topic (as in the
MeetingMinutes example) with a hidden input field named
"Approval" and value
"%WIKIUSERNAME%".
--
PeterThoeny - 03 Jul 2005