diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2005-10-29 17:10:51 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2005-10-29 17:10:51 +0000 |
| commit | 7e0719efa6b579270601692f1125f88dd1e0002c (patch) | |
| tree | c1d058e17eede721d8ff7e2201ca7ea03f0d2811 | |
| parent | 2822f71d08f3a94a3e26bb80fa1dbcef7bf2f1db (diff) | |
Fixed #675: PasswordFields now respect length and maxlength params
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1022 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/core/formfields.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/django/core/formfields.py b/django/core/formfields.py index 9b9f0af1d1..48238cf050 100644 --- a/django/core/formfields.py +++ b/django/core/formfields.py @@ -215,6 +215,7 @@ class FormField: #################### class TextField(FormField): + input_type = "text" def __init__(self, field_name, length=30, maxlength=None, is_required=False, validator_list=[]): self.field_name = field_name self.length, self.maxlength = length, maxlength @@ -237,8 +238,8 @@ class TextField(FormField): maxlength = 'maxlength="%s" ' % self.maxlength if isinstance(data, unicode): data = data.encode(DEFAULT_CHARSET) - return '<input type="text" id="%s" class="v%s%s" name="%s" size="%s" value="%s" %s/>' % \ - (FORM_FIELD_ID_PREFIX + self.field_name, self.__class__.__name__, self.is_required and ' required' or '', + return '<input type="%s" id="%s" class="v%s%s" name="%s" size="%s" value="%s" %s/>' % \ + (self.input_type, FORM_FIELD_ID_PREFIX + self.field_name, self.__class__.__name__, self.is_required and ' required' or '', self.field_name, self.length, escape(data), maxlength) def html2python(data): @@ -246,11 +247,7 @@ class TextField(FormField): html2python = staticmethod(html2python) class PasswordField(TextField): - def render(self, data): - # value is always blank because we never want to redisplay it - return '<input type="password" id="%s" class="v%s%s" name="%s" value="" />' % \ - (FORM_FIELD_ID_PREFIX + self.field_name, self.__class__.__name__, self.is_required and ' required' or '', - self.field_name) + input_type = "password" class LargeTextField(TextField): def __init__(self, field_name, rows=10, cols=40, is_required=False, validator_list=[], maxlength=None): |
