Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
HTML5 placeholder for Django forms
from django.forms.forms import BoundField
boundfield_as_widget = BoundField.as_widget
def as_widget(self, widget=None, attrs=None, only_initial=False):
if attrs is None:
attrs = {}
attrs['placeholder'] = self.label
return boundfield_as_widget(self, widget=widget, attrs=attrs,
only_initial=only_initial)
BoundField.as_widget = as_widget
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment