def __init__(self, *args, **kwargs):
super(OrgLockForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-vertical'
self.helper.form_id = 'org-lock-form'
self.helper.form_method = 'post'
self.helper.layout = Layout(
FormActions(
Submit(
'action',
'Cancel',
css_class='slds-button slds-button--neutral',
),
Submit(
'action',
'Lock',
css_class='slds-button slds-button--destructive',
),
),
)
python类Layout()的实例源码
def __init__(self, *args, **kwargs):
super(OrgUnlockForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-vertical'
self.helper.form_id = 'org-unlock-form'
self.helper.form_method = 'post'
self.helper.layout = Layout(
FormActions(
Submit(
'action',
'Cancel',
css_class='slds-button slds-button--neutral',
),
Submit(
'action',
'Unlock',
css_class='slds-button slds-button--destructive',
),
),
)
def __init__(self, *args, **kwargs):
super(DeleteNotificationForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-vertical'
self.helper.form_id = 'delete-notification-form'
self.helper.form_method = 'post'
self.helper.layout = Layout(
FormActions(
Submit(
'action',
'Cancel',
css_class='slds-button slds-button--neutral',
),
Submit(
'action',
'Delete',
css_class='slds-button slds-button--destructive',
),
),
)
def __init__(self, *args, **kwargs):
super(SignupForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.form_tag = False
self.helper.form_show_labels = True
for field in self.fields:
self.fields[field].widget.attrs['placeholder'] = None
del self.fields[field].widget.attrs['placeholder']
self.helper.layout = Layout(
'first_name', 'last_name', 'username', 'account_type',
'email', 'password1', 'password2',
StrictButton(
'Sign Up', type='submit',
css_class='btn purple btn-large waves-effect waves-light right'
),
)
def __init__(self, *args, **kwargs):
super(CustomLoginForm, self).__init__(*args, **kwargs)
self.fields['password'].widget = forms.PasswordInput()
self.helper = FormHelper(self)
self.helper.col_class = False
self.helper.form_tag = False
self.helper.form_show_labels = True
for field in self.fields:
self.fields[field].widget.attrs['placeholder'] = None
del self.fields[field].widget.attrs['placeholder']
self.helper.layout = Layout(
'login', 'password', 'remember',
StrictButton(
'Sign In', type='submit', style='margin-top: 10px',
css_class="waves-effect btn-large blue waves-light btn right"),
)
def __init__(self, *args, **kwargs):
super(CustomChangePwdForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.form_tag = False
self.helper.form_show_labels = True
for field in self.fields:
self.fields[field].widget.attrs['placeholder'] = None
del self.fields[field].widget.attrs['placeholder']
self.helper.layout = Layout(
'oldpassword', 'password1', 'password2',
StrictButton(
'Change Password', type='submit', name='action',
css_class='btn blue waves-effect waves-light btn-large')
)
def __init__(self, *args, **kwargs):
super(CustomResetPwdForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.form_tag = False
self.helper.form_show_labels = True
del self.fields['email'].widget.attrs['placeholder']
self.fields['email'].label = "Email Address"
self.helper.layout = Layout(
'email',
StrictButton(
'Reset My Password', type='submit',
css_class='btn blue btn-large waves-effect waves-light')
)
def __init__(self, *args, **kwargs):
super(CustomResetPasswordKeyForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.form_tag = False
self.helper.form_show_labels = True
for field in self.fields:
self.fields[field].widget.attrs['placeholder'] = None
del self.fields[field].widget.attrs['placeholder']
self.helper.layout = Layout(
'password1', 'password2',
StrictButton(
'Change Password', type='submit',
css_class='btn blue btn-large waves-effect waves-light')
)
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user')
super(BlogForm, self).__init__(*args, **kwargs)
# a little housekeeping
self.fields['is_public'].label = 'Publicly visible'
self.fields['short_description'].widget.attrs['class'] = 'materialize-textarea' # noqa
# making forms crispy
self.helper = FormHelper(self)
self.helper.layout = Layout(
'title', 'tag_line', 'short_description', 'is_public',
StrictButton(
'Create a Blog', type='submit',
css_class='btn blue btn-large right waves-effect waves-light'
)
)
def __init__(self, *args, **kwargs):
device = kwargs.pop('device')
self.device = device
signed_secret = kwargs.pop('secret', None) # used for setup flow
self.secret = signed_secret
super().__init__(*args, **kwargs)
self.helper = FormHelper()
submit = Submit('submit', _('Log in'), css_class='pull-right')
self.helper.layout = Layout(
Field('response', autofocus='autofocus'),
submit)
if signed_secret:
self.helper.layout.append(Hidden('secret', signed_secret))
submit.value = _('Add authenticator')
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field('username'),
Field('password'),
Field('email'),
Field('mc_username'),
Field('irc_nick'),
Field('gh_username'),
FormActions(
HTML("""<a href="{{% url 'accounts:login' %}}" """
"""class="btn btn-default">{}</a> """.format(
_("Log in"))),
Submit('sign up', _("Sign up")),
css_class="pull-right"
)
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field('username'),
HTML("""<i class="pull-right forgot-link">"""
"""<a tabindex="-1" href="{{% url 'accounts:forgot' %}}">"""
"""{}</a></i>""".format(_("Forgot your password?"))),
Field('password'),
HTML("""<div class="g-signin2 pull-left" """
"""data-onsuccess="onGoogleSignIn" """
"""data-theme="dark"></div>"""),
FormActions(
HTML("""<a href="{{% url 'accounts:register' %}}" """
"""class="btn btn-default">{}</a> """.format(
_("Sign up"))),
Submit('log in', _("Log in")),
css_class="pull-right"
)
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.form_id = 'create_user_form'
self.helper.form_method = 'post'
self.helper.form_action = reverse('backoffice:create-user')
self.helper.add_input(Submit('submit', 'User anlegen'))
self.helper.label_class = 'col-lg-2'
self.helper.field_class = 'col-lg-8'
self.helper.layout = Layout(
'username',
'password',
'firstname',
'lastname',
'is_backoffice_user',
'is_troubleshooter',
)
def helper(self):
# As extra service, auto-adjust the layout based on the project settings.
# This allows defining the top-row, and still get either 2 or 3 columns
compact_fields = [name for name in self.fields.keys() if name in self.top_row_fields]
other_fields = [name for name in self.fields.keys() if name not in self.top_row_fields]
col_size = int(self.top_row_columns / len(compact_fields))
col_class = self.top_column_class.format(size=col_size)
compact_row = Row(*[Column(name, css_class=col_class) for name in compact_fields])
# The fields are already ordered by the AbstractCommentForm.__init__ method.
# See where the compact row should be.
pos = list(self.fields.keys()).index(compact_fields[0])
new_fields = other_fields
new_fields.insert(pos, compact_row)
helper = CompactLabelsCommentFormHelper()
helper.layout = Layout(*new_fields)
helper.add_input(SubmitButton())
helper.add_input(PreviewButton())
return helper
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'main_form'
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-lg-2'
self.helper.field_class = 'col-lg-10'
self.helper.layout = Layout(
'player_name',
'xws_file',
FormActions(
Submit('run', 'Import'),
)
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'main_form'
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-lg-3'
self.helper.field_class = 'col-lg-8'
self.helper.layout = Layout(
Field(
'squad_one',
css_class="typeahead",
),
Field(
'squad_two',
css_class="typeahead",
),
'start_time',
'match_minutes',
FormActions(
Submit('save', 'Create Match'),
)
)
dashboard_forms.py 文件源码
项目:CommunityCellularManager
作者: facebookincubator
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(SubscriberInfoForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id-SubscriberInfoForm'
self.helper.form_method = 'post'
params = {
'imsi': kwargs.get('initial').get('imsi')
}
self.helper.form_action = urlresolvers.reverse(
'subscriber-edit', kwargs=params)
# Hide the label for the sub vacuum prevention radio.
self.fields['prevent_automatic_deactivation'].label = ''
self.helper.layout = Layout(
'imsi',
'name',
'prevent_automatic_deactivation',
Submit('submit', 'Save', css_class='pull-right'),
)
dashboard_forms.py 文件源码
项目:CommunityCellularManager
作者: facebookincubator
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(SubscriberCreditUpdateForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id-SubscriberCreditUpdateForm'
self.helper.form_method = 'post'
params = {
'imsi': kwargs.get('initial').get('imsi')
}
self.helper.form_action = urlresolvers.reverse(
'subscriber-adjust-credit', kwargs=params)
self.helper.form_class = 'col-xs-12 col-md-10 col-lg-8'
self.helper.layout = Layout(
'imsi',
FieldWithButtons('amount',
StrictButton('Add', css_class='btn-default',
type='submit')))
dashboard_forms.py 文件源码
项目:CommunityCellularManager
作者: facebookincubator
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(SubscriberSendSMSForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id-SubscriberSendSMSForm'
self.helper.form_method = 'post'
params = {
'imsi': kwargs.get('initial').get('imsi')
}
self.helper.form_action = urlresolvers.reverse('subscriber-send-sms',
kwargs=params)
self.helper.form_class = 'col-xs-12 col-md-8 col-lg-6'
self.helper.layout = Layout(
'imsi',
FieldWithButtons('message',
StrictButton('Send', css_class='btn-default',
type='submit')))
dashboard_forms.py 文件源码
项目:CommunityCellularManager
作者: facebookincubator
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(SubVacuumForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'inactive-subscribers-form'
self.helper.form_method = 'post'
self.helper.form_action = '/dashboard/network/inactive-subscribers'
# Render the inactive_days field differently depending on whether or
# not this feature is active.
if args[0]['sub_vacuum_enabled']:
days_field = Field('inactive_days')
else:
days_field = Field('inactive_days', disabled=True)
self.helper.layout = Layout(
'sub_vacuum_enabled',
days_field,
Submit('submit', 'Save', css_class='pull-right'),
)
def __init__(self, *args, **kwargs):
super(MessageRecipientForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-md-3'
self.helper.field_class = 'col-md-8'
self.fields['recipient_approved_public'].label = "I agree to publish this message and display it publicly in the Happiness Archive."
self.fields['recipient_approved_public_named'].label = "... and I agree to display our names publicly too."
self.fields['recipient_approved_public_named'].help_text = "Note: We only publish information if both the sender and the recipients agree."
self.helper.layout = Layout(
Fieldset("Privacy and permissions", 'recipient_approved_public', 'recipient_approved_public_named'),
HTML("<br>"),
Submit('submit', 'Save privacy choices', css_class='btn-lg centered'),
)
forms.py 文件源码
项目:Django-Web-Development-with-Python
作者: PacktPublishing
项目源码
文件源码
阅读 25
收藏 0
点赞 0
评论 0
def __init__(self, *args, **kwargs):
super(BulletinFilterForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_action = ""
self.helper.form_method = "GET"
self.helper.layout = layout.Layout(
layout.Fieldset(
_("Filter bulletins"),
layout.Field("bulletin_type"),
layout.Field("category"),
),
bootstrap.FormActions(
layout.Submit("submit", _("Filter")),
),
)
def __init__(self, *args, **kwargs):
super(SponsorContactForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
Field("responded"),
Field("companyName"),
Field("contactEMail"),
HTML("<p class=\"text-info\">Please ensure the correctness of the address. It will later be used in the billing process.</p>"),
Field("street"),
Field("zipcode"),
Field("city"),
Field("country"),
Field("contactPersonFirstname"),
Field("contactPersonSurname"),
Field("contactPersonGender"),
Field("contactPersonEmail"),
Field("contactPersonLanguage"),
Field("template"),
Field("comment")
)
self.helper.add_input(Submit("Save", "Save"))
def __init__(self,*args,**kwargs):
self._request = kwargs.pop('request',None)
user = getattr(self._request,'user',None)
payAtDoor = kwargs.pop('payAtDoor',False)
super(PrivateLessonStudentInfoForm,self).__init__(*args,**kwargs)
self.helper = FormHelper()
self.helper.form_method = 'post'
self.helper.form_tag = False # Our template must explicitly include the <form tag>
if user and hasattr(user,'customer') and user.customer and not payAtDoor:
# Input existing info for users who are logged in and have signed up before
self.fields['firstName'].initial = user.customer.first_name or user.first_name
self.fields['lastName'].initial = user.customer.last_name or user.last_name
self.fields['email'].initial = user.customer.email or user.email
self.fields['phone'].initial = user.customer.phone
self.helper.layout = Layout(
Div('firstName','lastName','email',css_class='form-inline'),
Div('phone',css_class='form-inline'),
Div('agreeToPolicies',css_class='card card-body bg-light'),
Submit('submit',_('Complete Registration'))
)
def __init__(self, *args, **kwargs):
super(PrettyFormPlaceholdersMixin, self).__init__(*args, **kwargs)
helper = self.helper
layout = helper.layout = Layout()
for field_name in self.fields:
field = self.fields[field_name]
label = field.label if field.label else field_name.capitalize()
layout.append(
Field(
field_name,
placeholder= label + (' *' if field.required else ''),
template=helper.field_template, css_class='pretty_field'
),
)
helper.form_show_labels = False
def __init__(self, *args, **kwargs):
self.object = kwargs.pop('instance')
super(InquiryResponseMixin, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-lg-2'
self.helper.field_class = 'col-lg-8'
layout_elements = list(self.fields.keys())
layout = layout_elements + [
StrictButton(_(u'Send your response'),
css_class='btn-success btn-lg', type='submit')
]
self.helper.layout = Layout(*layout)
def __init__(self, *args, **kwargs):
super(EventForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-lg-2'
self.helper.field_class = 'col-lg-8'
self.helper.form_method = 'post'
self.helper.form_action = 'newEvent'
self.helper.layout = Layout(
Field('name'),
Field('date', placeholder='yyyy-mm-dd (h24-MM)'),
HTML('<hr>'),
Field('end_date', placeholder='yyyy-mm-dd (h24-MM)'),
Field('description'),
Field('url'),
Field('username'),
Field('password'),
Field('location'),
Field('min_score'),
Field('max_score'),
FormActions(
Submit('save', 'Save')
)
)
def __init__(self, *args, **kwargs):
super(ChallengeForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-lg-2'
self.helper.field_class = 'col-lg-8'
self.helper.form_method = 'post'
self.helper.layout = Layout(
Field('name'),
Field('points'),
HTML('<hr>'),
Field('flag'),
FormActions(
Submit('save', 'Save')
)
)
def helper(self):
helper = FormHelper()
helper.form_id = 'id-searchForm'
helper.form_method = 'get'
helper.form_action = ''
helper.layout = Layout(
Fieldset(
'',
'well',
'addr',
'legal',
'owner',
# start_lat_long and end_lat_long are programatically generated
# based on an identifyWells operation on the client.
Hidden('start_lat_long', ''),
Hidden('end_lat_long', ''),
),
FormActions(
Submit('s', 'Search', css_class='formButtons'),
HTML('<a class="btn btn-default" id="reset-id-s" href="{% url \'search\' %}">Reset</a>'),
)
)
return helper
def __init__(self, *args, **kwargs):
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.disable_csrf = True
self.helper.form_show_labels = False
self.helper.render_required_fields = True
self.helper.render_hidden_fields = True
self.helper.layout = Layout(
HTML('<tr valign="top">'),
HTML('<td>'),
'liner_perforation_from',
HTML('</td>'),
HTML('<td>'),
'liner_perforation_to',
HTML('</td><td width="75"> {% if form.instance.pk %}{{ form.DELETE }}{% endif %}</td>'),
HTML('</tr>'),
)
super(LinerPerforationForm, self).__init__(*args, **kwargs)