Opened 13 years ago
Last modified 10 years ago
#16304 closed New feature
Forms Need HTML5 'placeholder' attribute — at Initial Version
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | forms, placeholder, html5 |
Cc: | Simon Charette, Kushagra Sinha, Andy Baker, lrekucki@…, claire12.reynaud@…, javi.manzano.oller@…, martmatwarne | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | yes | UI/UX: | yes |
Description
HTML5 introduces a 'placeholder' attribute to form inputs, providing a text hint which disappears when the user highlights it, which greatly improves the UX of a page.
To do this in Django currently, you have to do something like:
comment = forms.CharField(max_length=200, widget=forms.TextInput({ "placeholder": "Text!"}))
However, to do this with a ModelForm is much more complicated: http://bitkickers.blogspot.com/2010/09/django-html5-input-placeholders.html
I suggest that there should be an easier way to set placeholder text in form fields and model form fields:
comment = forms.CharField(max_length=200, placeholder="Text!")
(This would also be a good starting point for other new HTML5 input elements, such as 'required' and 'email', but those should be separate tickets. The code would be very similar though.)
What do you think?