本文整理匯總了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)