Tags:
create new tag
view all tags

SID-02104: How to include multiple forms in the same page?

Status: Answered Answered TWiki version: 6.0.1 Perl version:
Category: CategoryForms Server OS: RedHat Last update: 10 years ago

I created the following form with different names multiple times and add each of this form to a single page, but when I add a comment in one form it gets applied in all of the section instead of applying to only its section. Not sure what I am doing wrong. Any advice will be greatly appreciated:

Form:


%STARTINCLUDE%
<form name="new" action="%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/%INCLUDINGWEB%/">
%SEARCH{
 "%INCLUDINGTOPIC%"
 web="%INCLUDINGWEB%"
 topic="FAQ*"
 scope="all"
 regex="on"
 nosearch="on"
 nosummary="on"
 nototal="on"
 order="created"
 format="   1. $pattern(.*?FAQ\:\s*([^\n\r]+).*) [[%INCLUDINGWEB%.$topic][Answer...]] %BR%"
}% 

    <input type="hidden" name="topic" value="FAQ%SERVERTIME{"$yearx$mox$dayx$houx$minx$sec"}%" size="32" />
    <input type="hidden" name="topicparent" value="%INCLUDINGWEB%.%INCLUDINGTOPIC%" />
    <input type="hidden" name="onlynewtopic" value="on" />
    <input type="hidden" name="templatetopic" value="%INCLUDINGWEB%.TnPMainFAQ"/> %BR%
    <input type="submit" value="Add FAQ" /> 
</form>
%STOPINCLUDE%

In the main page including them as follows:

---++ MSA How Tos

Please click Add FAQ button to add new MSA How Tos:

%INCLUDE{"MSAFAQ"}%

---++ MMSC How Tos

Please click Add FAQ button to add new MMSC How Tos:

%INCLUDE{"MMSCFAQ"}%

-- Lisan Haq - 2015-09-17

Discussion and Answer

I don't think I understand all here, but one potential issue jumps to my mind: If you include multiple topics that specify the same date-based topic name "FAQ%SERVERTIME{"$yearx$mox$dayx$houx$minx$sec"}%" you will overwrite the topic if you submit more than one form.

To get around this problem use AUTOINCn to get unique topic names. Example: "FAQAUTOINC0001" produces "FAQ0001", "FAQ0002", etc.

Alternatively, use %CALCULATE{$INT(%SERVERTIME{$epoch}%+1)}%, and change the +1 in each included topic so that you get unique topic names.

-- Peter Thoeny - 2015-09-18

Thank you very much for replying to my question. I am trying to create How To twiki for different subjects. Since not everyone is familiar with twiki codes, I decided to create a form, which will allow them just input information and click add button. However, when I add a topic for one section the topic is presented in all the sections. I apply the above workaround you suggested, but the results remain the same. Maybe I didn't follow your suggestion correctly.

I change the following line from:

<input type="hidden" name="topic" value="FAQ%SERVERTIME{"$yearx$mox$dayx$houx$minx$sec"}%" size="32" />

to

<input type="hidden" name="topic" value="FAQAUTOINC0001%CALCULATE{$INT(%SERVERTIME{$epoch}%+1)}%" size="32" />

-- Lisan Haq - 2015-09-18

I also have difficulties to understand the idea, but I'll try a guess, too: When you create a new topic in your form (or your different forms MSAFAQ and MMSCFAQ, if I understand you correctly), then this new topic FAQ2015x09x19x18x21x22 apparently does not contain any information to which of the section it belongs. Your SEARCH also does not distinguish between the different sections, but will pick up all topics created by the forms.

To distinguish between the sections, you would need to make sure that every new topic contains the information to which section it belongs, and that the SEARCH picks only the relevant topics. So you indeed need different forms in MSAFAQ and MMSCFAQ, like this (boldface for changes) for the MSAFAQ section:

%STARTINCLUDE%
<form name="new" action="%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/%INCLUDINGWEB%/">
%SEARCH{
 "%INCLUDINGTOPIC%"
 web="%INCLUDINGWEB%"
 topic="MSAFAQ*"
 scope="all"
 regex="on"
 nosearch="on"
 nosummary="on"
 nototal="on"
 order="created"
 format="   1. $pattern(.*?FAQ\:\s*([^\n\r]+).*) [[%INCLUDINGWEB%.$topic][Answer...]] %BR%"
}% 

    <input type="hidden" name="topic" value="MSAFAQ%SERVERTIME{"$yearx$mox$dayx$houx$minx$sec"}%" size="32" />
    <input type="hidden" name="topicparent" value="%INCLUDINGWEB%.%INCLUDINGTOPIC%" />
    <input type="hidden" name="onlynewtopic" value="on" />
    <input type="hidden" name="templatetopic" value="%INCLUDINGWEB%.TnPMainFAQ"/> %BR%
    <input type="submit" value="Add FAQ" /> 
</form>
%STOPINCLUDE%

-- Harald Jörg - 2015-09-19

Thank you Harald. That fixed my issue.

-- Lisan Haq - 2015-09-22

Thank you Harald. That fixed my issue.

-- Lisan Haq - 2015-09-22

Thank you Harald.

-- Lisan Haq - 2015-09-22

      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 include multiple forms in the same page?
SupportCategory CategoryForms
TWiki version 6.0.1
Server OS RedHat
Web server

Perl version

Browser & version

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2015-09-22 - LisanHaq
 
  • 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.