Python crispy_forms.helper.FormHelper() Examples

The following are 30 code examples of crispy_forms.helper.FormHelper(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module crispy_forms.helper , or try the search function .
Example #1
Source File: forms.py    From tom_base with GNU General Public License v3.0 7 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse('tom_observations:add-existing')
        self.helper.layout = Layout(
            'target_id',
            'confirm',
            Row(
                Column(
                    'facility'
                ),
                Column(
                    'observation_id'
                ),
                Column(
                    ButtonHolder(
                        Submit('submit', 'Add Existing Observation')
                    )
                )
            )
        ) 
Example #2
Source File: forms.py    From osler with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):

        super(ActionItemForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)

        self.helper.layout = Layout(
            Row(
                Column(css_class='form-group col-md-3 col-xs-4'),
                Column('due_date', css_class='form-group col-md-3 col-xs-4'),
                Column('instruction', css_class='form-group col-md-3 col-xs-4'),
                css_class='form-row'
            ),
            Row(
                Column(css_class='form-group col-md-3 col-xs-4'),
                Column('comments', css_class='form-group col-md-6 col-xs-6')
            ),
            CustomCheckbox('priority'),
            Row(
                Column(Submit('submit', 'Submit'),
                    css_class='formgroup col-md-offset-3 col-xs-offset-4')
            )
        )

        self.fields['instruction'].queryset = models.ActionInstruction.objects.filter(
            active=True) 
Example #3
Source File: forms.py    From tom_base with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse('tom_observations:update', kwargs={'pk': self.initial.get('obsr_id')})
        self.helper.layout = Layout(
            'obsr_id',
            Row(
                Column(
                    'observation_id'
                ),
                Column(
                    ButtonHolder(
                        Submit('submit', 'Update Observation Id')
                    ),
                )
            )
        ) 
Example #4
Source File: forms.py    From happinesspackets with Apache License 2.0 6 votes vote down vote up
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'),
        ) 
Example #5
Source File: __init__.py    From anytask with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        AuthenticationForm.__init__(self, *args, **kwargs)
        self.error_messages['invalid_login'] = _(u"Пожалуйста, введите верные имя пользователя / адрес электронной почты  и пароль.")
        self.fields['username'].label = _(u"Логин / E-mail")

        self.helper = FormHelper(self)
        self.helper.form_action = '/accounts/login/'
        self.helper.label_class = 'col-md-4'
        self.helper.field_class = 'col-md-8'
        self.helper.layout.append(HTML(u"""<div class="form-group row" style="margin-bottom: 16px;margin-top: -16px;">
                                             <div class="col-md-offset-4 col-md-8">
                                               <a href="{% url "django.contrib.auth.views.password_reset" %}"><small class="text-muted">""" + _(u'Забыли пароль?') + """</small></a>
                                             </div>
                                           </div>
                                           <div class="form-group row">
                                             <div class="col-md-offset-4 col-md-8">
                                               <button type="submit" class="btn btn-secondary">""" + _(u'Войти') + """</button>
                                               <input type="hidden" name="next" value="{{ next }}" />
                                             </div>
                                           </div>""")) 
Example #6
Source File: forms.py    From osler with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(DemographicsForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
                Fieldset('Medical',
                         'has_insurance',
                         'ER_visit_last_year',
                         'last_date_physician_visit',
                         'chronic_condition'),
                Fieldset('Social',
                         'lives_alone',
                         'dependents',
                         'resource_access',
                         'transportation'),
                Fieldset('Employment',
                         'currently_employed',
                         'education_level',
                         'work_status',
                         'annual_income')
        )

        self.helper.add_input(Submit('submit', 'Submit')) 
Example #7
Source File: __init__.py    From anytask with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        AuthenticationForm.__init__(self, *args, **kwargs)
        self.error_messages['invalid_login'] = _(u"Пожалуйста, введите верные имя пользователя / адрес электронной почты  и пароль.")
        self.fields['username'].label = _(u"Логин / E-mail")

        self.helper = FormHelper(self)
        self.helper.form_action = '/accounts/login/'
        self.helper.label_class = 'col-md-4'
        self.helper.field_class = 'col-md-8'
        self.helper.layout.append(HTML(u"""<div class="form-group row" style="margin-bottom: 16px;margin-top: -16px;">
                                             <div class="col-md-offset-4 col-md-8">
                                               <a href="{% url "django.contrib.auth.views.password_reset" %}"><small class="text-muted">""" + _(u'Забыли пароль?') + """</small></a>
                                             </div>
                                           </div>
                                           <div class="form-group row">
                                             <div class="col-md-offset-4 col-md-8">
                                               <button type="submit" class="btn btn-secondary">""" + _(u'Войти') + """</button>
                                               <input type="hidden" name="next" value="{{ next }}" />
                                             </div>
                                           </div>""")) 
Example #8
Source File: forms.py    From conf_site with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        self.user = kwargs.pop("user")
        kwargs.update(
            {
                "initial": {
                    "contact_name": self.user.get_full_name,
                    "contact_email": self.user.email,
                }
            }
        )
        super(SponsorApplicationForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.field_class = "col-sm-10 col-lg-10"
        self.helper.form_tag = False
        self.helper.label_class = "col-sm-2 col-lg-2"
        self.helper.layout = Layout(
            "name",
            "external_url",
            "contact_name",
            "contact_email",
            "level",
        ) 
Example #9
Source File: forms.py    From oxidizr with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(KeywordCreateForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_id = 'id_form_keywords_create'
        self.helper.layout = Layout(
            Div(
                Div(
                    'term',
                    css_class='col-sm-6 col-sm-offset-3'
                ),
                css_class='row'
            ),
            HTML('''<hr class="full">'''),
            Div(
                Div(
                    HTML('''<a href="{% url 'keywords_manage' %}">{{ _('Cancel') }}</a>&nbsp;&nbsp;'''),
                    Submit('submit', _('Save'), css_class='btn-success btn-lg'),
                    css_class='pull-right'
                ),
                css_class='row',
            )
        ) 
Example #10
Source File: forms.py    From oxidizr with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(ResetPasswordForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_id = 'id_form_reset_password'
        self.helper.layout = Layout(
            Div(
                'verification_code',
                'password',
                'repeat_password',
            ),
            HTML('''<hr class="full">'''),
            Div(
                Div(
                    HTML('''<a href="{% url 'accounts_login' %}"> {{ _('Cancel and login') }}</a>&nbsp;&nbsp;'''),
                    Submit('submit', _('Reset password'), css_class='btn-success btn-lg'),
                    css_class='pull-right'
                )
            )
        ) 
Example #11
Source File: forms.py    From oxidizr with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        self._email_token = kwargs.pop('email_token', None)
        self._verification_code = self._email_token.verification_code
        super(EmailVerificationForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_id = 'id_form_email_verification'
        self.helper.form_action = reverse_lazy('accounts_email_verification', args=(self._email_token.id,))
        self.helper.layout = Layout(
            Div(
                'code',
            ),
            HTML('''<hr class="full">'''),
            Div(
                Div(
                    HTML('''<a href="{% url 'accounts_register' %}">
                    {{ _('Cancel and sign up again') }}</a>&nbsp;&nbsp;'''),
                    Submit('submit', _('Verify Email address'), css_class='btn-success btn-lg'),
                    css_class='pull-right'
                )
            )
        ) 
Example #12
Source File: forms.py    From osler with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        referral_location_qs = kwargs.pop('referral_location_qs', None)
        super(PatientContactForm, self).__init__(*args, **kwargs)
        if referral_location_qs is not None:
            self.fields['appointment_location'].queryset = referral_location_qs

        self.helper = FormHelper(self)
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-8'

        self.helper.add_input(Submit(
            self.SUCCESSFUL_REFERRAL,
            'Save & mark successful referral',
            css_class='btn btn-success'))
        self.helper.add_input(Submit(
            self.REQUEST_FOLLOWUP,
            'Save & request future followup',
            css_class='btn btn-info'))
        self.helper.add_input(Submit(
            self.UNSUCCESSFUL_REFERRAL,
            'Save & do not follow up again',
            css_class='btn btn-danger btn-sm')) 
Example #13
Source File: forms.py    From oxidizr with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(ForgotPasswordForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_id = 'id_form_forgot_password'
        self.helper.layout = Layout(
            Div(
                'email',
            ),
            HTML('''<hr class="full">'''),
            Div(
                Div(
                    HTML('''<a href="{% url 'accounts_login' %}"> {{ _('Cancel and login') }}</a>&nbsp;&nbsp;'''),
                    Submit('submit', _('Continue'), css_class='btn-success btn-lg'),
                    css_class='pull-right'
                )
            )
        ) 
Example #14
Source File: forms.py    From advanced-crispy-forms-examples with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column('email', css_class='form-group col-md-6 mb-0'),
                Column('password', css_class='form-group col-md-6 mb-0'),
                css_class='form-row'
            ),
            'address_1',
            'address_2',
            Row(
                Column('city', css_class='form-group col-md-6 mb-0'),
                Column('state', css_class='form-group col-md-4 mb-0'),
                Column('zip_code', css_class='form-group col-md-2 mb-0'),
                css_class='form-row'
            ),
            CustomCheckbox('check_me_out'),
            Submit('submit', 'Sign in')
        ) 
Example #15
Source File: forms.py    From advanced-crispy-forms-examples with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Column('email', css_class='form-group col-md-6 mb-0'),
                Column('password', css_class='form-group col-md-6 mb-0'),
                css_class='form-row'
            ),
            'address_1',
            'address_2',
            Row(
                Column('city', css_class='form-group col-md-6 mb-0'),
                Column('state', css_class='form-group col-md-4 mb-0'),
                Column('zip_code', css_class='form-group col-md-2 mb-0'),
                css_class='form-row'
            ),
            'check_me_out',
            Submit('submit', 'Sign in')
        ) 
Example #16
Source File: forms.py    From ontask_b with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()

        self.helper.layout = Layout(
            Field('new_password1', placeholder='Enter new password',
                  autofocus=''),
            Field('new_password2', placeholder='Enter new password (again)'),
            Submit('pass_change',
                   'Change Password',
                   css_class='btn-outline-primary'),
        ) 
Example #17
Source File: forms.py    From ontask_b with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()

        self.helper.layout = Layout(
            Field('old_password', placeholder='Enter old password',
                  autofocus=''),
            Field('new_password1', placeholder='Enter new password'),
            Field('new_password2', placeholder='Enter new password (again)'),
            Submit('pass_change',
                   'Change Password',
                   css_class='btn-outline-primary'),
        ) 
Example #18
Source File: forms.py    From InvenTree with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(forms.ModelForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()

        self.helper.form_tag = False

        """
        Create a default 'layout' for this form.
        Ref: https://django-crispy-forms.readthedocs.io/en/latest/layouts.html
        This is required to do fancy things later (like adding PrependedText, etc).

        Simply create a 'blank' layout for each available field.
        """

        self.rebuild_layout() 
Example #19
Source File: forms.py    From django-lb-workflow with MIT License 5 votes vote down vote up
def after_create_formset(self, form_class_key, formset):
        super().after_create_formset(form_class_key, formset)
        helper = FormHelper()
        helper.template = 'lbadminlte/bootstrap3/table_inline_formset.html'
        formset.helper = helper
        return formset 
Example #20
Source File: forms.py    From osler with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(ProviderForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.form_method = 'post'
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-8'
        self.helper['languages'].wrap(InlineCheckboxes)
        self.helper['clinical_roles'].wrap(InlineCheckboxes)
        self.helper.add_input(Submit('submit', 'Submit')) 
Example #21
Source File: forms.py    From Collaboration-System with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
		role = kwargs.pop('role', None)
		mtype = kwargs.pop('mediatype', None)
		super().__init__(*args, **kwargs)
		self.fields['title'].widget.attrs.update({'class': 'form-control'})
		self.fields['state'].widget.attrs.update({'class': 'form-control'})
		states = getStatesCommunity(self.instance.state.id, role)
		self.fields['state'].queryset = States.objects.filter(name__in=states)
		self.fields['mediafile'].required = False
		if mtype == 'IMAGE':
		    self.fields['mediafile'].widget.attrs.update({'class': 'file', 'data-allowed-file-extensions':'["jpeg", "jpg","png"]', 'data-show-upload':'false', 'data-show-preview':'false', 'data-msg-placeholder':'Select image for upload...'})
		if mtype == 'AUDIO':
		    self.fields['mediafile'].widget.attrs.update({'class': 'file', 'data-allowed-file-extensions':'["mp3"]', 'data-show-upload':'false', 'data-show-preview':'false', 'data-msg-placeholder':'Select audio for upload...'})
		if mtype == 'VIDEO':
		    self.fields['mediafile'].widget.attrs.update({'class': 'file', 'data-allowed-file-extensions':'["mp4"]', 'data-show-upload':'false', 'data-show-preview':'false', 'data-msg-placeholder':'Select video for upload...'})

		self.fields['medialink'].widget.attrs.update({'class': 'form-control'})
		self.fields['medialink'].required = False

		self.helper = FormHelper()
		self.helper.layout = Layout(
			Div(
                Field('title'),
                Field('media_type'),
                Field('medialink'),
                Field('mediafile'),
				Field('state'),
                HTML("<br>"),
                ButtonHolder(Submit('submit', 'Update')),
                )
		) 
Example #22
Source File: forms.py    From Collaboration-System with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
		mtype = kwargs.pop('mediatype', None)
		super().__init__(*args, **kwargs)
		self.fields['title'].widget.attrs.update({'class': 'form-control'})
		self.fields['mediafile'].required = False
		if mtype == 'IMAGE':
		    self.fields['mediafile'].widget.attrs.update({'class': 'file', 'data-allowed-file-extensions':'["jpeg", "jpg","png"]', 'data-show-upload':'false', 'data-show-preview':'false', 'data-msg-placeholder':'Select image for upload...'})
		if mtype == 'AUDIO':
		    self.fields['mediafile'].widget.attrs.update({'class': 'file', 'data-allowed-file-extensions':'["mp3"]', 'data-show-upload':'false', 'data-show-preview':'false', 'data-msg-placeholder':'Select audio for upload...'})
		if mtype == 'VIDEO':
		    self.fields['mediafile'].widget.attrs.update({'class': 'file', 'data-allowed-file-extensions':'["mp4"]', 'data-show-upload':'false', 'data-show-preview':'false', 'data-msg-placeholder':'Select video for upload...'})

		self.fields['medialink'].widget.attrs.update({'class': 'form-control'})
		self.fields['medialink'].hidden = True
		self.fields['medialink'].required = False
		self.fields['media_type'].initial = 'Upload'

		self.helper = FormHelper()
		self.helper.layout = Layout(
			Div(
                Field('title'),
                Field('media_type'),
                Field('medialink','value'),
                Field('mediafile'),
                HTML("<br>"),
                ButtonHolder(Submit('submit', 'Create')),
                )
		) 
Example #23
Source File: forms.py    From Collaboration-System with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
		super().__init__(*args, **kwargs)
		self.helper = FormHelper()
		self.helper.layout = Layout(
			Div(
                Field('description'),
                HTML("<br>"),
                ButtonHolder(Submit('submit', 'Save')),
                )
		)

		for key in Schema:
			self.fields[key]=forms.CharField(label = key, required = False) 
Example #24
Source File: forms.py    From osler with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(DocumentForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.add_input(Submit('submit', 'Submit')) 
Example #25
Source File: forms.py    From osler with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(AppointmentForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.add_input(Submit('submit', 'Submit')) 
Example #26
Source File: forms.py    From osler with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, referral_location_qs, *args, **kwargs):
        super(ReferralForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.fields['location'].widget = forms.widgets.CheckboxSelectMultiple()
        self.fields['location'].queryset = referral_location_qs
        self.helper.add_input(Submit('submit', 'Create referral')) 
Example #27
Source File: forms.py    From osler with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(ClinicDateForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-2'
        self.helper.field_class = 'col-lg-8'

        self.helper.add_input(Submit('submit', 'Submit')) 
Example #28
Source File: forms.py    From osler with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        super(FollowupRequestForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.add_input(Submit('submit', 'Submit')) 
Example #29
Source File: forms.py    From osler with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.helper.add_input(Submit('followup_close', 'Submit and Close Action', css_class = 'btn btn-warning'))
        self.helper.add_input(Submit('followup_create', 'Submit and Create Action', css_class = 'btn btn-info'))
        super(BaseFollowup, self).__init__(*args, **kwargs) 
Example #30
Source File: forms.py    From osler with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, pt_id, *args, **kwargs):
        super(ReferralSelectForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()

        self.fields['referrals'].queryset = models.Referral.objects\
            .filter(
                patient_id=pt_id,
                status=models.Referral.STATUS_PENDING,
                followuprequest__isnull=False,
                # followuprequest__patientcontact__isnull=True
        )

        self.helper.add_input(Submit('submit', 'Submit'))