mirror of
https://github.com/Hopiu/django-select2.git
synced 2026-04-23 14:34:45 +00:00
Merge pull request #156 from onysos/master
fix on 4.2.2 with django 1.7 : is_hidden = True
This commit is contained in:
commit
32c1e1eb5b
2 changed files with 30 additions and 1 deletions
|
|
@ -341,9 +341,15 @@ class MultipleSelect2HiddenInput(forms.TextInput):
|
|||
data_set = set([force_text(value) for value in data])
|
||||
return data_set != initial_set
|
||||
|
||||
@property
|
||||
def is_hidden(self):
|
||||
# we return false because even if input_type is 'hidden'
|
||||
# , the final field will be displayed by javascript
|
||||
# and we want label and other layout elements.
|
||||
return False
|
||||
|
||||
# ## Heavy mixins and widgets ##
|
||||
|
||||
# ## Heavy mixins and widgets ###
|
||||
|
||||
class HeavySelect2Mixin(Select2Mixin):
|
||||
"""
|
||||
|
|
@ -529,6 +535,13 @@ class HeavySelect2Widget(HeavySelect2Mixin, forms.TextInput):
|
|||
def init_options(self):
|
||||
self.options['multiple'] = False
|
||||
|
||||
@property
|
||||
def is_hidden(self):
|
||||
# we return false because even if input_type is 'hidden'
|
||||
# , the final field will be displayed by javascript
|
||||
# and we want label and other layout elements.
|
||||
return False
|
||||
|
||||
|
||||
class HeavySelect2MultipleWidget(HeavySelect2Mixin, MultipleSelect2HiddenInput):
|
||||
"""
|
||||
|
|
|
|||
16
tests/test_widgets.py
Normal file
16
tests/test_widgets.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# -*- coding:utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
||||
|
||||
|
||||
class TestWidgets(object):
|
||||
url = ""
|
||||
|
||||
def test_is_hidden_multiple(self):
|
||||
from django_select2.widgets import HeavySelect2MultipleWidget
|
||||
new_widget = HeavySelect2MultipleWidget(data_url="/")
|
||||
assert new_widget.is_hidden is False
|
||||
|
||||
def test_is_hidden(self):
|
||||
from django_select2.widgets import HeavySelect2Widget
|
||||
new_widget = HeavySelect2Widget(data_url="/")
|
||||
assert new_widget.is_hidden is False
|
||||
Loading…
Reference in a new issue