本文整理匯總了Python中plone.app.widgets.dx.SelectWidget.id方法的典型用法代碼示例。如果您正苦於以下問題:Python SelectWidget.id方法的具體用法?Python SelectWidget.id怎麽用?Python SelectWidget.id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類plone.app.widgets.dx.SelectWidget
的用法示例。
在下文中一共展示了SelectWidget.id方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_widget_set_not_orderable
# 需要導入模塊: from plone.app.widgets.dx import SelectWidget [as 別名]
# 或者: from plone.app.widgets.dx.SelectWidget import id [as 別名]
def test_widget_set_not_orderable(self):
from plone.app.widgets.dx import SelectWidget
widget = SelectWidget(self.request)
widget.id = 'test-widget'
# A set is not orderable
widget.field = Set(
__name__='selectfield',
value_type=Choice(values=['one', 'two', 'three'])
)
widget.terms = widget.field.value_type.vocabulary
self.assertEqual(
{
'multiple': True,
'name': None,
'pattern_options': {
'multiple': True, 'separator': ';'},
'pattern': 'select2',
'value': (),
'items': [
('one', 'one'),
('two', 'two'),
('three', 'three')
]
},
widget._base_args(),
)
示例2: test_select
# 需要導入模塊: from plone.app.widgets.dx import SelectWidget [as 別名]
# 或者: from plone.app.widgets.dx.SelectWidget import id [as 別名]
def test_select(self):
from plone.app.widgets.dx import SelectWidget
request = TestRequest(environ={'HTTP_ACCEPT_LANGUAGE': 'en'},
example='example-value')
widget = SelectWidget(request)
widget.id = 'example'
widget.name = 'example'
widget.field = TextLine(__name__='selectfield')
widget.field.vocabulary = SimpleVocabulary.fromValues(
['option1', 'option2', 'option3'])
widget.terms = widget.field.vocabulary
self.assertEqual(
widget._widget_args(),
{
'name': 'example',
'pattern': 'select2',
'pattern_options': {},
'options': [('--NOVALUE--', u'No value'),
('option1', 'option1'),
('option2', 'option2'),
('option3', 'option3')],
'selected': (),
},
)
示例3: test_widget
# 需要導入模塊: from plone.app.widgets.dx import SelectWidget [as 別名]
# 或者: from plone.app.widgets.dx.SelectWidget import id [as 別名]
def test_widget(self):
from plone.app.widgets.dx import SelectWidget
widget = SelectWidget(self.request)
widget.id = 'test-widget'
widget.field = Choice(
__name__='selectfield',
values=['one', 'two', 'three']
)
widget.terms = widget.field.vocabulary
widget.field.required = True
self.assertEqual(
{
'multiple': None,
'name': None,
'pattern_options': {},
'pattern': 'select2',
'value': (),
'items': [
('one', 'one'),
('two', 'two'),
('three', 'three')
]
},
widget._base_args(),
)
widget.field.required = False
self.assertEqual(
{
'multiple': None,
'name': None,
'pattern_options': {'allowClear': True},
'pattern': 'select2',
'value': (),
'items': [
(u'', u''),
('one', 'one'),
('two', 'two'),
('three', 'three')
]
},
widget._base_args(),
)
widget.field.required = True
widget.multiple = True
self.assertEqual(
{
'multiple': True,
'name': None,
'pattern_options': {'separator': ';', 'multiple': True},
'pattern': 'select2',
'value': (),
'items': [
('one', 'one'),
('two', 'two'),
('three', 'three')
]
},
widget._base_args(),
)
widget.field.required = False
widget.multiple = True
self.assertEqual(
{
'multiple': True,
'name': None,
'pattern_options': {'allowClear': True,
'separator': ';',
'multiple': True},
'pattern': 'select2',
'value': (),
'items': [
('one', 'one'),
('two', 'two'),
('three', 'three')
]
},
widget._base_args(),
)
widget.value = 'one'
self.assertEqual(
{
'multiple': True,
'name': None,
'pattern_options': {'allowClear': True,
'separator': ';',
'multiple': True},
'pattern': 'select2',
'value': ('one'),
'items': [
('one', 'one'),
('two', 'two'),
('three', 'three')
]
},
widget._base_args(),
)