Login

Tag "placeholder"

Snippet List

Decorator to add placeholders to field

Decorator to automagically add placeholders to form widgets. `cls` can be any class derived from `django.forms.Form` or `django.forms.ModelForm`. The field labels are used as value for the placeholder. This will affect all form instances of this class. * add_placeholders only to forms.TextInput and form.Textarea * add_placeholders_to_any_field adds placeholders to any field Usage: @add_placeholders class Form(forms.Form): name = forms.CharField The name field will render as `<input type="text" placeholder="name">`

  • decorator
  • placeholder
Read More

2 snippets posted so far.