Tags:
create new tag
, view all tags

SID-02301: how to have a password field in tiwki forms

Status: Answered Answered TWiki version: 6.0.1 Perl version:
Category: CategoryForms Server OS: RedHat Linux Last update: 6 months ago

There is a requirement to get input from user as username and password. As user types in the password it should not be visible to user instead asterics should be shown.

I Tried below code with twiki form template. But on submitting the form I am not bale to get the data entered in password field. <form name="bugForm" action="%SCRIPTURLPATH{"save"}%/%WEB%/" method="post">

Login: %EDITFORMFIELD{ "login" form="BugSearchForm"}%
Password: %EDITFORMFIELD{"password" type="password" form="BugSearchForm"}%
  <input type="submit" class="twikiSubmit" value="Login" />
<input type="hidden" name="topicparent" value="TestBugList" /> <input type="hidden" name="templatetopic" value="SearchTemplate" /> <input type="hidden" name="topic" value="CreateBugResult" /> <input type="hidden" name="onlywikiname" value="on" /> <input type="hidden" name="onlynewtopic" value="off" /> </form>

Can someone help me to fix this?

Thanks

-- TWiki Guest - 2017-02-21

Discussion and Answer

A few questions: - can you get the data that is entered into the login field? - if you remove the type="password" can you get the data that was entered into the password field?

-- Jani Hamalainen - 2017-02-24

Yes I am able to get data from login field. Also if I remove type="password" I am able to get what is entered in that field.

-- TWiki Guest - 2017-02-28

The easy solution: You'll be able to get the data of your password field if you just omit form="BugSearchForm" from your EDITFORMFIELD parameters. There's another solution which looks weird, but if you're interested, read on.

You can get a lot of hidden features out of TWiki, but you need to be aware of the hidden traps.

The hidden feature: The EDITFORMFIELD variable does not officially take a type of password, but as you noted, it is accepted, and it displays correctly.

The hidden trap: If you read TWiki.VarEDITFORMFIELD carefully, then you see that the form attribute is only required if there's no type, but you have type="password". And for all types which are not officially supported, TWiki simply retains all other parameters of EDITFORMFIELD and passes them as attributes for the input element, in case they are required by the input type. In your case, this applies to the form attribute, which in your case has the value of "BugSearchForm". Just inspect the HTML source of your page - there it is. So, where's the trap? The form attribute is, incidentally, also a perfectly valid attribute for an input element. And it has an interesting meaning: An input element with a form="BugSearchForm" doesn't belong to this form. Instead, it belongs to a form with the attribute id="BugSearchForm".

So, this is the weird solution: If you add id="BugSearchForm" to your form element, you'll also be able to get the value of the password field.

Finally, I am pretty sure that you know that the password field will be visible in plain sight in your CreateBugReport topic. There are no hidden fields in TWiki.TWikiForms.

-- Harald Jörg - 2017-02-28

Thanks Harald for the solution.

Yes you are right I know password filed will be visible in topic created.

-- TWiki Guest - 2017-03-01

      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 have a password field in tiwki forms
SupportCategory CategoryForms
TWiki version 6.0.1
Server OS RedHat Linux
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 - 2017-03-01 - TWikiGuest
 
  • 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.