Ticket #3409: password-input.diff
File password-input.diff, 1.8 KB (added by , 18 years ago) |
---|
-
django/newforms/widgets.py
81 81 class PasswordInput(Input): 82 82 input_type = 'password' 83 83 84 def __init__(self, attrs=None, render_value=True): 85 self.attrs = attrs or {} 86 self.render_value = render_value 87 88 def render(self, name, value, attrs=None): 89 if not self.render_value: value=None 90 return super(PasswordInput, self).render(name, value, attrs) 91 84 92 class HiddenInput(Input): 85 93 input_type = 'hidden' 86 94 is_hidden = True -
tests/regressiontests/forms/tests.py
72 72 >>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) 73 73 u'<input type="password" class="fun" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" name="email" />' 74 74 75 You can specify if the widget should render its value or not: 76 >>> w = PasswordInput(render_value=True) 77 >>> w.render('email', 'secret') 78 u'<input type="password" name="email" value="secret" />' 79 >>> w = PasswordInput(render_value=False) 80 >>> w.render('email', '') 81 u'<input type="password" name="email" />' 82 >>> w.render('email', None) 83 u'<input type="password" name="email" />' 84 >>> w.render('email', 'secret') 85 u'<input type="password" name="email" />' 86 >>> w = PasswordInput(attrs={'class': 'fun'}, render_value=False) 87 >>> w.render('email', 'secret') 88 u'<input type="password" class="fun" name="email" />' 89 75 90 # HiddenInput Widget ############################################################ 76 91 77 92 >>> w = HiddenInput()