Tags:
create new tag
view all tags

SID-00049: How to duplicate a TWiki form-based page?

Status: Answered Answered TWiki version: 4.1.1 Perl version:
Category: CategoryForms Server OS: Last update: 17 years ago

I have a form-based application where users can submit work requests. The form template consists of two dozen fields, a combination of textarea, text, and select fields.

Since a user may submit several requests that differ only in one or two fields, I want the user to be able to select a work request and push a "Duplicate" button to be able to create a new page that prepopulates most of its content from the selected page; then they can change a few fields and create the new page.

Is there an easy way to do this? I couldn't find a generic solution in the support pages, documentation, or the web.

The path I'm starting down is having a report page where each row is a work request. Each row also has an HTML form with a "Duplicate" submit button and invisible fields containing all the information from that particular request. When the user presses the button, I create a new form, passing all the old fields via the "?" query string. The template is set up to initialize each field with the appropriate original contents (via URLPARAM). This results in very wordy and error-prone code for all two dozen fields; plus some of the text fields contain line feeds, double-quotes, etc. which are making it painful to reconstruct all the original fields faithfully in the duplicate. Should I continue with this approach and try various flavors of "ENCODE" (maybe along with "newline=" in my percent SEARCH command)? Or is there some better way that I'm overlooking?

I am using TWiki-4.1.1, but we can upgrade if there's a more recent build that would make things easier.

-- AndyEvans - 21 Jan 2009

Discussion and Answer

Why not simply use an existing page you want to duplicate for the topictemplate parameter? See MeetingMinutes example.

-- PeterThoeny - 21 Jan 2009

Thanks for the quick response. I tried it and it works to copy over all the fields. I see that I didn't understand the interaction between the templatetopic and formtemplate parameters. All the examples on our own site have them set to the same thing.

What if I want to specify some values for the duplicate that are not the same as the original? How would I pass along some new values for a few of the fields? Is there anything that can override the values in the page specified by 'templatetopic'? Would I need to do some scripting that can recognize the difference between a new page and a duplicate page, and if it's a duplicate page, replace the contents of those few fields?

-- AndyEvans - 21 Jan 2009

Yes, simply add FieldName=Some_Value parameters, typically supplied by a visible text field or a hidden field in an HTML form. For inspiration check out the form in AskSupportQuestion.

-- PeterThoeny - 22 Jan 2009

That works well. I had seen the mention that "Initial values can then be provided in the URLs or as form values:" on the "TWikiForms" topic, but I didn't realize that there was a hierarchy - the URL would override the templatetopic. It does make sense that it behaves this way.

-- AndyEvans - 22 Jan 2009

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title How to duplicate a TWiki form-based page?
SupportCategory CategoryForms
TWiki version 4.1.1
Server OS

Web server

Perl version

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2009-01-22 - AndyEvans
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.