本文整理汇总了Python中horizon.forms.CheckboxInput方法的典型用法代码示例。如果您正苦于以下问题:Python forms.CheckboxInput方法的具体用法?Python forms.CheckboxInput怎么用?Python forms.CheckboxInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类horizon.forms
的用法示例。
在下文中一共展示了forms.CheckboxInput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CheckboxInput [as 别名]
def __init__(self, request, context, *args, **kwargs):
super(CreateRouterAssociationInfoAction, self).__init__(
request, context, *args, **kwargs)
# when an admin user uses the project panel BGPVPN, there is no
# tenant_id in context because bgpvpn_get doesn't return it
if request.user.is_superuser and context.get("project_id"):
tenant_id = context.get("project_id")
else:
tenant_id = self.request.user.tenant_id
try:
routers = api.neutron.router_list(request, tenant_id=tenant_id)
if routers:
choices = [('', _("Choose a router"))] + [(r.id, r) for r in
routers]
self.fields['router_resource'].choices = choices
else:
self.fields['router_resource'].choices = [('', _("No router"))]
except Exception:
exceptions.handle(request, _("Unable to retrieve routers"))
if api.neutron.is_extension_supported(request,
'bgpvpn-routes-control'):
self.fields['with_parameters'] = forms.BooleanField(
label=_("Optional parameters"),
initial=False,
required=False,
widget=forms.CheckboxInput(attrs={
'class': 'switchable',
'data-hide-tab': 'router_association__'
'add_router_parameters',
'data-hide-on-checked': 'false'
}))
示例2: __init__
# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CheckboxInput [as 别名]
def __init__(self, request, *args, **kwargs):
super(UpdateImageForm, self).__init__(request, *args, **kwargs)
self.fields['disk_format'].choices = [(value, name) for value,
name in IMAGE_FORMAT_CHOICES
if value]
if not policy.check((("image", "publicize_image"),), request):
self.fields['public'].widget = forms.CheckboxInput(
attrs={'readonly': 'readonly'})
示例3: build_control
# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CheckboxInput [as 别名]
def build_control(parameter):
attrs = {"priority": parameter.priority,
"placeholder": parameter.default_value}
if parameter.param_type == "string":
return forms.CharField(
widget=forms.TextInput(attrs=attrs),
label=parameter.name,
required=(parameter.required and
parameter.default_value is None),
help_text=parameter.description,
initial=parameter.initial_value)
if parameter.param_type == "int":
return forms.IntegerField(
widget=forms.TextInput(attrs=attrs),
label=parameter.name,
required=parameter.required,
help_text=parameter.description,
initial=parameter.initial_value)
elif parameter.param_type == "bool":
return forms.BooleanField(
widget=forms.CheckboxInput(attrs=attrs),
label=parameter.name,
required=False,
initial=parameter.initial_value,
help_text=parameter.description)
elif parameter.param_type == "dropdown":
return forms.ChoiceField(
widget=forms.Select(attrs=attrs),
label=parameter.name,
required=parameter.required,
choices=parameter.choices,
help_text=parameter.description)