本文整理汇总了Python中crispy_forms.layout.Fieldset方法的典型用法代码示例。如果您正苦于以下问题:Python layout.Fieldset方法的具体用法?Python layout.Fieldset怎么用?Python layout.Fieldset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类crispy_forms.layout
的用法示例。
在下文中一共展示了layout.Fieldset方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.layout = Layout(
layout.Fieldset(
'',
layout.Field('recipient', readonly=True),
'subject',
'body',
'referenced_post',
),
bootstrap.FormActions(
Submit('submit', 'Send Message', css_class='btn btn-success'),
)
)
self.helper.form_tag = False
示例2: __init__
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def __init__(self, *args, **kwargs):
super(TaskPairChooseCauseTaskForm, self).__init__(*args, **kwargs)
if 'cause_agent' in kwargs.get('initial', {}):
self.fields['cause_task'].choices = [
(task_name, getattr(task, 'label', task_name))
for task_name, task in AgentConfig.objects.get(
pk=kwargs['initial']['cause_agent']).agent.cause_tasks.items()]
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = Layout(Fieldset(
'Choose a Cause',
'cause_agent',
*submit_buttons_from_choicefield(
'cause_task', self.fields['cause_task'], kwargs.get('prefix')
)
))
示例3: __init__
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def __init__(self, request, *args, **kwargs):
self.request = request
super().__init__(*args, **kwargs)
id_field = layout.Field("id")
language_field = layout.Field("language", css_class="input-block-level")
title_field = layout.Field("title", css_class="input-block-level")
content_field = layout.Field("content", css_class="input-block-level", rows="3")
delete_field = layout.Field("DELETE")
main_fieldset = layout.Fieldset(
_("Main data"),
id_field,
language_field,
title_field,
content_field,
delete_field,
)
self.helper = helper.FormHelper()
self.helper.form_tag = False
self.helper.disable_csrf = True
self.helper.layout = layout.Layout(main_fieldset)
示例4: __init__
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
author_field = layout.Field("author")
category_field = layout.Field("category")
rating_field = layout.Field("rating")
submit_button = layout.Submit("filter", _("Filter"))
actions = bootstrap.FormActions(submit_button)
main_fieldset = layout.Fieldset(
_("Filter"),
author_field,
category_field,
rating_field,
actions,
)
self.helper = helper.FormHelper()
self.helper.form_method = "GET"
self.helper.layout = layout.Layout(main_fieldset)
示例5: __init__
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def __init__(self, legend, *fields, **kwargs):
self.description = kwargs.pop('description', None)
self.collapsed = kwargs.pop('collapsed', None)
super(Fieldset, self).__init__(legend, *fields, **kwargs)
示例6: _add_user_data_subform
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def _add_user_data_subform(self, user_data):
self._validate_user_data(user_data)
if user_data:
# Translators: This labels a section of a form where we ask users to enter personal information (such as their country of residence) when making an application.
user_data_layout = Fieldset(_("About you"))
for datum in user_data:
self.fields[datum] = FIELD_TYPES[datum]
self.fields[datum].label = FIELD_LABELS[datum]
# Show which partner wants which personal data if applying
# for more than one.
if len(self.field_params) > 1:
# fmt: off
# Translators: This text is shown in the application form under each piece of personal information requested. {partner_list} will be a list of 2 or more organisations that require this personal data, and should not be translated.
self.fields[datum].help_text = _("Requested by: {partner_list}").format(
partner_list=", ".join(user_data[datum])
),
# fmt: on
user_data_layout.append(datum)
self.helper.layout.append(user_data_layout)
# fmt: off
# Translators: This note appears in a section of a form where we ask users to enter info (like country of residence) when applying for resource access.
disclaimer_html = _("<p><small><i>Your personal data will be processed according to our <a href='{terms_url}'> privacy policy</a>.</i></small></p>").format(
terms_url=reverse("terms")
)
# fmt: on
self.helper.layout.append(HTML(disclaimer_html))
示例7: __init__
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def __init__(self, request, *args, **kwargs):
self.request = request
super().__init__(*args, **kwargs)
self.fields["categories"].widget = forms.CheckboxSelectMultiple()
title_field = layout.Field("title")
content_field = layout.Field("content", rows="3")
main_fieldset = layout.Fieldset(_("Main data"), title_field, content_field)
picture_field = layout.Field("picture")
format_html = layout.HTML(
"""{% include "ideas2/includes/picture_guidelines.html" %}"""
)
picture_fieldset = layout.Fieldset(
_("Picture"),
picture_field,
format_html,
title=_("Image upload"),
css_id="picture_fieldset",
)
categories_field = layout.Field("categories")
categories_fieldset = layout.Fieldset(
_("Categories"), categories_field, css_id="categories_fieldset"
)
submit_button = layout.Submit("save", _("Save"))
actions = bootstrap.FormActions(submit_button)
self.helper = helper.FormHelper()
self.helper.form_action = self.request.path
self.helper.form_method = "POST"
self.helper.layout = layout.Layout(
main_fieldset,
picture_fieldset,
categories_fieldset,
actions,
)
示例8: __init__
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def __init__(self, request, *args, **kwargs):
parent = kwargs.pop('parent', None)
super(PageCreateForm, self).__init__(*args, **kwargs)
if parent:
self.fields['parent'].initial = parent
if request.method == 'GET':
color_scheme_fields = self.init_color_scheme_switch(
color_scheme=kwargs['initial'].get('color_scheme', None))
self.helper.layout = Layout(
TabHolder(
Tab(_('Main'),
'title',
'language',
'translation_of',
'parent',
'site',
css_id='page-main'
),
Tab(_('Navigation'),
'in_navigation', 'slug',
'override_url', 'redirect_to',
'symlinked_page', 'navigation_extension'
),
Tab(_('Heading'),
'_content_title', '_page_title',
css_id='page-heading'
),
Tab(_('Publication'),
'active', 'featured', 'publication_date',
'publication_end_date', 'meta_description',
'meta_keywords'
),
Tab(_('Theme'),
'template_key', 'layout', Fieldset(
'Themes', 'theme', *color_scheme_fields),
css_id='page-theme-settings'
),
)
)
self.fields['color_scheme'].required = False
示例9: __init__
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def __init__(self, *args, **kwargs):
try:
self.field_params = kwargs.pop("field_params")
except KeyError:
logger.exception(
"Tried to instantiate a RenewalForm but did not have field_params"
)
raise
super(RenewalForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
# Translators: This will be the title of the page where users will have to confirm their renewal request of an application.
fieldset = Fieldset(_("Renewal confirmation"))
account_email = False
if (
"account_email" in self.field_params
and self.field_params["account_email"] is not None
):
self.fields["account_email"] = forms.EmailField(
initial=self.field_params["account_email"]
)
account_email = True
elif "account_email" in self.field_params:
self.fields["account_email"] = forms.EmailField()
account_email = True
if account_email:
# fmt: off
# Translators: This labels an email field where users will be asked to enter their emails as part of the application renewal confirmation.
self.fields["account_email"].label = _("The email for your account on the partner's website")
# fmt: on
fieldset.append("account_email")
if "requested_access_duration" in self.field_params:
self.fields["requested_access_duration"] = forms.ChoiceField(
choices=Application.REQUESTED_ACCESS_DURATION_CHOICES
)
# fmt: off
# Translators: This labels a choice field where users will have to select the number of months they wish to have their access for as part of the application renewal confirmation.
self.fields["requested_access_duration"].label = _("The number of months you wish to have this access for before renewal is required")
# fmt: on
fieldset.append("requested_access_duration")
self.fields["return_url"] = forms.CharField(
widget=forms.HiddenInput, max_length=70
)
self.fields["return_url"].initial = self.field_params["return_url"]
fieldset.append("return_url")
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.form_class = "form-horizontal"
self.helper.label_class = "col-lg-3"
self.helper.field_class = "col-lg-4"
self.helper.layout = Layout()
self.helper.layout.append(fieldset)
示例10: __init__
# 需要导入模块: from crispy_forms import layout [as 别名]
# 或者: from crispy_forms.layout import Fieldset [as 别名]
def __init__(self, request, *args, **kwargs):
self.request = request
super().__init__(*args, **kwargs)
geoposition = self.instance.get_geoposition()
if geoposition:
self.fields["latitude"].initial = geoposition.latitude
self.fields["longitude"].initial = geoposition.longitude
name_field = layout.Field("name", css_class="input-block-level")
description_field = layout.Field(
"description", css_class="input-block-level", rows="3"
)
main_fieldset = layout.Fieldset(_("Main data"), name_field, description_field)
picture_field = layout.Field(
"picture",
data_url=reverse("upload_file"),
template="core/includes/file_upload_field.html",
)
picture_path_field = layout.Field("picture_path")
picture_fieldset = layout.Fieldset(
_("Picture"),
picture_field,
picture_path_field,
title=_("Picture upload"),
css_id="picture_fieldset",
)
street_address_field = layout.Field(
"street_address", css_class="input-block-level"
)
street_address2_field = layout.Field(
"street_address2", css_class="input-block-level"
)
postal_code_field = layout.Field("postal_code", css_class="input-block-level")
city_field = layout.Field("city", css_class="input-block-level")
country_field = layout.Field("country", css_class="input-block-level")
latitude_field = layout.Field("latitude", css_class="input-block-level")
longitude_field = layout.Field("longitude", css_class="input-block-level")
address_fieldset = layout.Fieldset(
_("Address"),
street_address_field,
street_address2_field,
postal_code_field,
city_field,
country_field,
latitude_field,
longitude_field,
)
submit_button = layout.Submit("save", _("Save"))
actions = bootstrap.FormActions(layout.Div(submit_button, css_class="col"))
self.helper = helper.FormHelper()
self.helper.form_action = self.request.path
self.helper.form_method = "POST"
self.helper.attrs = {"noValidate": "noValidate"}
self.helper.layout = layout.Layout(main_fieldset, picture_fieldset, address_fieldset, actions)