Fix BootsrapForm: placeholder on Input and Textarea only.
This commit is contained in:
parent
94c2168af1
commit
5052bd8ddc
@ -13,6 +13,11 @@ Added
|
|||||||
-----
|
-----
|
||||||
* Add Django 1.10 support
|
* Add Django 1.10 support
|
||||||
|
|
||||||
|
Fixed
|
||||||
|
-----
|
||||||
|
* Fix BootsrapForm: placeholder on Input and Textarea only, use class form-control on
|
||||||
|
Input, Select and Textarea.
|
||||||
|
|
||||||
|
|
||||||
v0.7.1 - 2016-08-24
|
v0.7.1 - 2016-08-24
|
||||||
===================
|
===================
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
from .default_settings import settings
|
from .default_settings import settings
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.forms import widgets
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import cas_server.utils as utils
|
import cas_server.utils as utils
|
||||||
@ -27,12 +28,12 @@ class BootsrapForm(forms.Form):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(BootsrapForm, self).__init__(*args, **kwargs)
|
super(BootsrapForm, self).__init__(*args, **kwargs)
|
||||||
for field in self.fields.values():
|
for field in self.fields.values():
|
||||||
# Only tweak the fiel if it will be displayed
|
# Only tweak the field if it will be displayed
|
||||||
if not isinstance(field.widget, forms.HiddenInput):
|
if not isinstance(field.widget, widgets.HiddenInput):
|
||||||
attrs = {}
|
attrs = {}
|
||||||
if not isinstance(field.widget, forms.CheckboxInput):
|
if isinstance(field.widget, (widgets.Input, widgets.Select, widgets.Textarea)):
|
||||||
attrs['class'] = "form-control"
|
attrs['class'] = "form-control"
|
||||||
if field.label: # pragma: no branch (currently all field are hidden or labeled)
|
if isinstance(field.widget, (widgets.Input, widgets.Textarea)) and field.label:
|
||||||
attrs["placeholder"] = field.label
|
attrs["placeholder"] = field.label
|
||||||
if field.required:
|
if field.required:
|
||||||
attrs["required"] = "required"
|
attrs["required"] = "required"
|
||||||
|
Loading…
Reference in New Issue
Block a user