SID-02331: Use a form to update a webpage
| Status: |
Answered |
TWiki version: |
|
Perl version: |
|
| Category: |
CategoryForms |
Server OS: |
|
Last update: |
8 years ago |
Hello,
I'm trying to figure out how to write a user form that will send an update to another webpage in TWiki. Ideally, this will be something that people without admin access will be able to do.
I created a form (
ProxyUpdateForm)
And I have a webpage (
TestProxyUpdate) where I would like people to fill out the form:
Update Proxy Expiration Date and Time
%EDITFORMFIELD{ "ProxyUpdateForm" type="start" action="view" method="post" }%
| Date | %EDITFORMFIELD{ "Date" type="date" form="ProxyUpdateForm" }% |
| Time | %EDITFORMFIELD{ "Time" type="text" form="ProxyUpdateForm" placeholder="hh:mm:ss" }% |
| Shifter | %EDITFORMFIELD{ "Shifter" type="text" form="ProxyUpdateForm" placeholder="Shifter Name" }% |
| | %EDITFORMFIELD{ "form" type="submit" value="Update" }% |
%EDITFORMFIELD{ "Updated" type="hidden" value="%SERVERTIME{$year-$mo-$day}%" }%
%EDITFORMFIELD{ "form" type="end" }%
** I'm not sure what the update button will do? How do I make it save the values input into the form??
Lastly I have a webpage that I want the values in the form to be pushed to when the "Update" button is pressed:
Proxy Expiry:
The Proxy will expire on : *search for form values here (date and time)
Proxy updated by: *search for form values here (shifter)
Expiration updated on: *search for form values here (updated)
To update proxy details:
TestProxyUpdate
I'm not sure what the correct syntax is to just get the variables I want.
Any help I could get would be very much appreciated.
Thanks,
Karin
--
TWiki Guest - 2017-09-20
Discussion and Answer
A good place to start is blog
How to Create a TWiki Application.
Your form action is the TWiki save script. You need to either ask the user for a topic name, or add a hidden form field for an auto-generated topic name. The idea is that on each submit, a new topic is created with the ProxyUpdateForm containing the values of the user input.
--
Peter Thoeny - 2017-09-28
Hi Peter,
The blog shows exactly what I would like to do! however, any time I hit Update it makes a copy of the sandbox home (Sandbox/WebHome) page and makes it a child of the main page without updating anything. I tried copying and pasting
ContactDB into my sandbox with
ContactForm,
ContactHeader,
ContactTemplate, and
NewContact, but the same behavior occurred where the table would not update and hitting "Create New Contact" on the
ContactDB page redirected me to Sandbox/WebHome. Do you have an idea why this might be happening? Am I missing some sort of plugin?
Thanks,
Karin
--
TWiki Guest - 2017-10-02
I got it to work! (not the contact example, but my stuff). I'm not sure what I did exactly, but here is the key part (my "NewProxy")
ProxyUpdateMainPage is the master page that the form will update to
ProxyTemplate is the template page that contains a
ProxyForm with Date, Time, and Shifter fields
%EDITFORMFIELD{"form" name="new" type="start" action="save" topic="LongTermProxyUpdate%SERVERTIME{$yearx$mox$day}%" method="post" }%
%EDITFORMFIELD{"templatetopic" type="hidden" value="ProxyTemplate"}%
%EDITFORMFIELD{"topicparent" type="hidden" value="ProxyUpdateMainPage" }%
| Date |
%EDITFORMFIELD{ "Date" type="date" }% |
| Time |
%EDITFORMFIELD{ "Time" type="text" placeholder="hh:mm:ss" }% |
| Shifter |
%EDITFORMFIELD{ "Shifter" type="text" placeholder="Shifter Name" }% |
| |
%EDITFORMFIELD{ "form" type="submit" class="twikiSubmit" value="Update" }% |
%EDITFORMFIELD{"form" type="end" }%
Begin able to look at your example was very helpful.
Thanks, Karin
--
TWiki Guest - 2017-10-03
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.