Reputation: 592
I have a password field that needs to be changes every once in a while. I have a regular:
form = SQLFORM(db.table, id)
I want to simply print the form to the view but with the following change: How do I stop Web2py from showing the * symbols and just show nothing at all so the user has to enter the new data every time any editing to the form occurs.
Currently it shows ****** with the values of ****** in html.
Do I really need to make a customer view for this issue? Users are getting confused about the form thinking it still contains a working password when it doesn't.
Upvotes: 0
Views: 63
Reputation: 25536
You can customize the widget of the password field:
db.mytable.password.widget = lambda f, v: SQLFORM.widgets.password.widget(f, v, _value='')
This can also be done in the table definition:
db.define_table('mytable',
...,
Field('password', 'password',
widget=lambda f, v: SQLFORM.widgets.password.widget(f, v, _value='')),
...)
If you want to make this change for all password fields in all applications, you can instead monkey patch the sqlhtml
module:
from gluon import sqlhtml
sqlhtml.DEFAULT_PASSWORD_DISPLAY = ''
Upvotes: 0