Code

Changes between Initial Version and Version 9 of Ticket #16304


Ignore:
Timestamp:
10/15/12 13:47:26 (21 months ago)
Author:
lrekucki
Comment:

Is there any reason why this is added only to CharField? placeholder is more of a widget thing, so it shouldn't matter on what type of field I define it as long as I use a widget that can render it. placeholder is also legal on <textarea> not only variations of <input type="...">.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16304

    • Property Status changed from new to assigned
    • Property Cc j4nu5, andybak added
    • Property Patch needs improvement set
    • Property Needs tests unset
    • Property Summary changed from Forms Need HTML5 'placeholder' attribute to Add HTML5 'placeholder' attribute support to form fields.
    • Property Version changed from 1.3 to SVN
    • Property Owner changed from nobody to j4nu5
    • Property Needs documentation unset
    • Property Has patch set
    • Property Triage Stage changed from Unreviewed to Accepted
  • Ticket #16304 – Description

    initial v9  
    33To do this in Django currently, you have to do something like: 
    44 
     5{{{#!python 
    56comment = forms.CharField(max_length=200, widget=forms.TextInput({ "placeholder": "Text!"})) 
     7}}} 
    68 
    79However, to do this with a ModelForm is much more complicated: http://bitkickers.blogspot.com/2010/09/django-html5-input-placeholders.html 
     
    911I suggest that there should be an easier way to set placeholder text in form fields and model form fields: 
    1012 
     13{{{#!python 
    1114comment = forms.CharField(max_length=200, placeholder="Text!") 
     15}}} 
    1216 
    1317(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.)