class contactForm(forms.ModelForm): helper = FormHelper() helper.form_tag = False helper.layout = Layout( TabHolder( Tab( 'Basic Information', 'firstName', 'lastName', 'phone', 'email', 'company', ), Tab( 'Shipping Address', 'address1', 'address2', 'city', 'state', 'zip', ), ) ) def __init__(self, *args, **kwargs): super(contactForm, self).__init__(*args, **kwargs) class Meta: model = contact exclude = ['cdID', ]
def __init__(self, *args, **kwargs): super(StudentForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = Layout( TabHolder( Tab( 'Personal Info', 'name', 'photo', 'date_of_birth', 'email', 'mobile', 'guardian_mobile', ), Tab('Departmental Info', Field('department', css_class="extra"), Field('semester', ), Field('ac_session', )), Tab( 'Board Info', Field('roll', css_class="extra"), Field('registration_number', ), )), ButtonHolder( Submit('submit', 'Admit Student', css_class='float-right btn-dark mr-3')))
def __init__(self, *args, **kwargs): super(SalesConfigForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'Invoices and quotations', Row( Column('default_invoice_comments', css_class='col-md-6 col-sm-12'), Column('default_credit_note_comments', css_class='col-md-6 col-sm-12')), Row( Column('default_quotation_comments', css_class='col-md-6 col-sm-12'), Column('default_terms', css_class='col-md-6 col-sm-12')), 'next_invoice_number', 'next_quotation_number', ), # Tab('Page Layout', # # 'sales_tax', # # 'include_tax_in_invoice', # # 'include_units_in_sales_invoice', # # 'include_shipping_address', # ), Tab( 'POS Settings', 'default_warehouse', ))) self.helper.add_input(Submit('submit', "Submit"))
def __init__(self, *args, **kwargs): super(UserCreationForm, self).__init__(*args, **kwargs) print "init is called again" self.helper.form_id = 'id_user_creation_form' self.helper.form_name = 'id_user_creation_form' self.helper.form_action = '/usermaster/createuser/' self.helper.layout = Layout( TabHolder( Tab( 'Mandatory Info', 'email', 'password', 'is_active', ), Tab( 'Basic Info', 'title', 'first_name', 'last_name', 'job_title', 'date_joined', 'date_expiry', ), Tab( 'Store Info', 'store_id', )), Div( Submit('submit', 'Submit', css_class='btn btn-default'), css_class='col-lg-offset-3 col-lg-9', ), )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'general', 'name', 'balance', Row( Column('balance_sheet_category', css_class='form-group col-md-6 col-sm-12'), Column('type', css_class='form-group col-md-6 col-sm-12'), ), 'description', ), Tab( 'account', # 'account_code', 'bank_account_number', 'parent_account', 'pk', Row( Column('control_account', css_class='form-group col-md-6 col-sm-12'), Column('bank_account', css_class='form-group col-md-6 col-sm-12'), ), ), )) self.helper.add_input(Submit('submit', 'Submit'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab('Basic', 'user', # 'avatar', 'email_address', 'email_password', # Row( # Column( css_class='form-group col-md-6 col-sm-12'), # Column(HTML(""" # {% load render_bundle from webpack_loader %} # {% render_bundle 'widgets' %} # <div id="avatar-preview"></div> # """), css_class='form-group col-md-6 col-sm-12'), # ) ), Tab('Advanced', 'outgoing_server', 'outgoing_port', 'incoming_host', 'incoming_port', 'max_email_age' ) ) ) self.helper.add_input(Submit('submit', 'Submit'))
def __init__(self, *args, **kwargs): super(StudentForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = Layout( TabHolder( Tab('Student Personal Info', 'username', 'first_name', 'email', 'password', 'password1', css_class="extra"), Tab('Student Register Info', 'photo', 'date_of_birth', 'registration_number', 'mobile', ), Tab('Student Payment Info', Field('total_amount', 'paid_amount', 'due_amount', ButtonHolder( Submit('submit', 'Admit Student', css_class='float-right btn-dark mr-3') ), css_class="extra"), ), ), )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = Layout( TabHolder(Tab('Info', 'name', 'description'), Tab('Variables', 'variables'), Tab('Ownership', 'owner_groups')))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = Layout( TabHolder(Tab('Info', 'name', 'description'), Tab('Access', 'username', 'password'), Tab('Ownership', 'owner_groups')))
def __init__(self, *args, **kwargs): super(LibroAddForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = Layout( TabHolder( Tab( _('Información Básica'), Field('titulo', wrapper_class="col-md-6"), Field('autor_libro', wrapper_class="col-md-6"), Field('creado_por', wrapper_class="col-md-6"), Field('editorial_libro', wrapper_class="col-md-12"), Field('documento', wrapper_class="col-md-12"), ), Tab( _('Otra Información'), ) ) ) self.helper.layout.append( FormActions( Submit('submit', _('Submit'), css_class='btn btn-primary'), ) )
def __init__(self, *args, **kwargs): super(LibroUpdateForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.fields['creado_por'].disabled = True disabled_widget = forms.Select(attrs={'disabled': True}) self.helper.layout = Layout( TabHolder( Tab( _('Información Básica'), Field('titulo', wrapper_class="col-md-6" ), Field('autor_libro', wrapper_class="col-md-6"), Field('creado_por', wrapper_class="col-md-8"), Field('editorial_libro', wrapper_class="col-md-12"), Field('documento', wrapper_class="col-md-12") ), Tab( _('Otra Información'), ) ) ) self.helper.layout.append( FormActions( Submit('submit', _('Submit'), css_class='btn btn-primary'), ) )
def __init__(self, *args, **kwargs): super(LibroViewForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = Layout( TabHolder( Tab( _('Información Básica'), Field('titulo', wrapper_class="col-md-6"), Field('autor_libro', wrapper_class="col-md-6"), Field('creado_por', wrapper_class="col-md-6"), Field('editorial_libro', wrapper_class="col-md-12"), Field('documento', wrapper_class="col-md-12"), HTML("""<iframe src="http://127.0.0.1:8000/media/documents/ase.pdf" style="width:100%; height:150%;" frameborder="0"></iframe> """) ), Tab( _('Otra Información'), ) ) ) self.helper.layout.append( FormActions( Submit('submit', _('Submit'), css_class='btn btn-primary'), ) )
class UserProfileForm(ModelForm): helper = FormHelper() helper.form_tag = True helper.form_method = "POST" helper.form_action = "/accounts/edit_profile/" helper.add_input(Submit('submit', 'Submit')) helper.layout = Layout( TabHolder( Tab( 'Basic Information', 'first_name', 'last_name', 'phone_number', 'ssn', ), Tab( 'Address', 'address1', 'address2', 'city', 'state', 'zip_code', ) ) ) class Meta: model = UserProfile fields = ('first_name', 'last_name', 'phone_number', 'ssn', 'address1', 'address2', 'city', 'state', 'zip_code',)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'Basic', Row( Column('first_name', css_class='form-group col-6'), Column('last_name', css_class='form-group col-6'), ), Row( Column('email', 'phone', css_class='form-group col-6'), Column('address', css_class='form-group col-6'), ), ), Tab( 'Personal', 'date_of_birth', 'id_number', 'gender', ), Tab('Conditions of service', 'pay_grade', 'leave_days', 'pin', 'uses_timesheet'))) self.helper.add_input(Submit('submit', 'Submit'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'Procedure Details', 'name', 'reference', 'author', 'description', ), Tab( 'procedure steps', HTML(""" <div id="procedure-widgets" style="display:block;clear:both"> </div> """)), Tab( 'Select Equipment And Consumables', HTML(""" <div id="inventory-widgets" style="display:block;clear:both"></div> """)), )) self.helper.add_input(Submit('submit', 'Submit'))
def __init__(self, *args, **kwargs): super(CustomerForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.form_tag = False self.helper.layout = Layout( TabHolder( Tab( _('Basic information'), Field('name', wrapper_class="col-md-6"), Field('email', wrapper_class="col-md-6"), Field('information', wrapper_class="col-md-12"), ), Tab( _('Time information'), Field('date', wrapper_class="col-md-4"), Field('time', wrapper_class="col-md-4"), Field('datetime', wrapper_class="col-md-4"), ), Tab( _('Image information'), Field('image', wrapper_class="col-md-4"), Field('cropping', wrapper_class="col-md-4"), Field('color', wrapper_class="col-md-4"), ))) self.helper.layout.append( FormActions( Submit('submit', _('Submit'), css_class='btn btn-primary'), HTML("""{% load i18n %}<a class="btn btn-danger" href="{{ url_delete }}">{% trans 'Delete' %}</a>"""), ))
def test_tab_and_tab_holder(self): test_form = TestForm() test_form.helper = FormHelper() test_form.helper.layout = Layout( TabHolder( Tab( 'one', 'first_name', css_id="custom-name", css_class="first-tab-class" ), Tab( 'two', 'password1', 'password2' ) ) ) html = render_crispy_form(test_form) assert html.count( '<li class="tab-pane active"><a href="#custom-name" data-toggle="tab">One</a></li>' ) == 1 assert html.count('class="tab-pane first-tab-class active"') == 1 assert html.count('<li class="tab-pane') == 2 assert html.count('tab-pane') == 4 assert html.count('<div id="custom-name"') == 1 assert html.count('<div id="two"') == 1 assert html.count('name="first_name"') == 1 assert html.count('name="password1"') == 1 assert html.count('name="password2"') == 1
def __init__(self, *args, **kwargs): super(InvoiceForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.form_tag = False self.helper.layout = Layout( TabHolder( Tab( _('Invoice'), Field('customer', wrapper_class="col-md-12"), Field('registered', wrapper_class="col-md-4"), Field('sent', wrapper_class="col-md-4"), Field('paid', wrapper_class="col-md-4"), Field('date', wrapper_class="col-md-6"), Field('invoice_number', wrapper_class="col-md-6"), Field('subtotal', wrapper_class="col-md-3"), Field('subtotal_iva', wrapper_class="col-md-3"), Field('subtotal_retentions', wrapper_class="col-md-3"), Field('total', wrapper_class="col-md-3"), ), Tab( _('Email'), Field('description1', wrapper_class="col-md-12"), Field('description2', wrapper_class="col-md-12"), ))) self.helper.layout.append( FormActions( Submit('submit', _('Submit'), css_class='btn btn-primary'), HTML("""{% load i18n %}<a class="btn btn-danger" href="{{ url_delete }}">{% trans 'Delete' %}</a>"""), ))
def __init__(self, *args, **kwargs): super(ClientBillForm, self).__init__(*args, **kwargs) self.helper.form_tag = False self.helper.layout = Layout( Div( TabHolder(Tab( _("Description"), Column("lead", "bill_id", "state", css_class="col-md-6"), Column("comment", "client_comment", "anonymize_profile", "include_timesheet", css_class="col-md-6"), ), Tab( _("Amounts"), Column("amount", "vat", "amount_with_vat", css_class="col-md-6")), Tab( _("Dates"), Column("creation_date", "due_date", "payment_date", css_class="col-md-6"), ), Tab( _("Advanced"), Column("client_deal_id", "lang", "bill_file", css_class="col-md-6"), ), css_class="row")))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab('Basic', 'date', Row( Column('amount', css_class='form-group col-6'), Column('debit_account', css_class='form-group col-6'), ), 'description', 'category', Row( Column('recorded_by', css_class='form-group col-6'), Column('reference', css_class='form-group col-6'), ) ), Tab('Billing', 'billable', 'customer', ), ) ) self.helper.add_input(Submit('submit', 'Submit'))
def test_tab_and_tab_holder(self, settings): test_form = SampleForm() test_form.helper = FormHelper() test_form.helper.layout = Layout( TabHolder( Tab("one", "first_name", css_id="custom-name", css_class="first-tab-class active"), Tab("two", "password1", "password2"), )) html = render_crispy_form(test_form) if settings.CRISPY_TEMPLATE_PACK == "bootstrap4": assert (html.count( '<ul class="nav nav-tabs"> <li class="nav-item">' '<a class="nav-link active" href="#custom-name" data-toggle="tab">One</a></li>' ) == 1) assert html.count("tab-pane") == 2 else: assert (html.count( '<ul class="nav nav-tabs"> <li class="tab-pane active">' '<a href="#custom-name" data-toggle="tab">One</a></li>') == 1) assert html.count('<li class="tab-pane') == 2 assert html.count("tab-pane") == 4 assert html.count('class="tab-pane first-tab-class active"') == 1 assert html.count('<div id="custom-name"') == 1 assert html.count('<div id="two"') == 1 assert html.count('name="first_name"') == 1 assert html.count('name="password1"') == 1 assert html.count('name="password2"') == 1
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'Email', 'email_address', 'email_password', 'smtp_server', 'smtp_port', 'default_reminder_email', ), Tab('Server', 'server_ip', 'server_domain', 'server_port', 'conn_account', 'conn_password', ), Tab('Report Config', 'DDC_reminder_days', 'company_name', 'speeding_threshold', 'harsh_braking_delta', 'daily_report_generation_time' ) ) ) self.helper.add_input(Submit('submit', 'Submit'))
def __init__(self, *args, **kwargs): super(UserDetailForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.form_method = 'POST' self.helper.label_class = 'col-lg-2' self.helper.field_class = 'col-lg-4' self.helper.layout = Layout( TabHolder( Tab( 'Mandatory Info', 'email', 'password', 'is_active', ), Tab( 'Basic Info', 'title', 'first_name', 'last_name', 'job_title', 'date_joined', 'date_expiry', ), Tab( 'Store Info', 'enterprise_id', 'store_id', )), Div( Submit('submit', 'Submit', css_class='btn btn-default'), css_class='col-lg-offset-3 col-lg-9', ), )
def __init__(self, *args, **kwargs): super(LinksForm, self).__init__(*args, **kwargs) self.helper.layout = Layout( TabHolder(Tab( _('Base'), 'id', 'name', 'slug', 'description', ), )) if 'request' in kwargs: from .tables import LinksTable _request = copy.copy(kwargs['request']) _request.POST = {} _request.method = 'GET' try: category = self._meta.model.objects.get( id=kwargs['initial']['id']) except: category = None data = [] else: data = category.link_set.all() dimensions = Tab( _('Links'), HTML( LinksTable(_request, category=category, data=data).render()), ) self.helper.layout[0].append(dimensions)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'basic', Row( Column('name', css_class='form-group col-md-6 col-sm-12'), Column('initialized_by', css_class='form-group col-md-6 col-sm-12'), ), Row( Column('initial_value', css_class='form-group col-md-6 col-sm-12'), Column('salvage_value', css_class='form-group col-md-6 col-sm-12'), ), Row( Column('depreciation_period', css_class='form-group col-md-6 col-sm-12'), Column('depreciation_method', css_class='form-group col-md-6 col-sm-12'), ), 'init_date', 'category', ), Tab( 'description', 'description', 'credit_account', ), )) self.helper.add_input(Submit('submit', 'Submit'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'Form', Row( Column('date', css_class="form group col-md-6 col-sm-12"), Column('time', css_class="form group col-md-6 col-sm-12"), ), 'works_request', 'description', 'completed', 'expected_duration', 'status', 'authorized_by', 'team', ), Tab( 'Service People', HTML(""" <div id="work-order-persons"></div> """), ), )) self.helper.add_input(Submit('submit', 'Submit'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'details', Row( Column('name', 'phone_1', 'email', css_class='form-group col-md-6 col-sm-12'), Column('customer_type', 'address', css_class='form-group col-md-6 col-sm-12'), ), ), Tab( 'other', 'website', 'phone_2', 'image', 'organization', Row( Column('banking_details', css_class='form-group col-md-6 col-sm-12'), Column('billing_address', css_class='form group col-md-6 col-sm-12')), 'other_details', ), ), Submit('submit', 'Submit'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'Basic', 'name', Row( Column('flat_fee', css_class='form-group col-md-6 col-sm-12'), Column('hourly_rate', css_class='form-group col-md-6 col-sm-12'), ), ), Tab( 'Other', 'description', Row( Column('category', css_class='form-group col-md-4 col-sm-12'), Column('procedure', css_class='form-group col-md-4 col-sm-12'), Column('frequency', css_class='form-group col-md-4 col-sm-12'), ), 'is_listed', )), Submit('submit', 'Submit'))
def test_tab_and_tab_holder(self): test_form = SampleForm() test_form.helper = FormHelper() test_form.helper.layout = Layout( TabHolder( Tab( "one", "first_name", css_id="custom-name", css_class="first-tab-class active", ), Tab("two", "password1", "password2"), )) html = render_crispy_form(test_form) assert (html.count( '<ul class="nav nav-tabs"> <li class="nav-item">' '<a class="nav-link active" href="#custom-name" data-bs-toggle="tab">' "One</a></li>") == 1) assert html.count("tab-pane") == 2 assert html.count('class="tab-pane first-tab-class active"') == 1 assert html.count('<div id="custom-name"') == 1 assert html.count('<div id="two"') == 1 assert html.count('name="first_name"') == 1 assert html.count('name="password1"') == 1 assert html.count('name="password2"') == 1
def get_form(self): form = super().get_form() form['body'].label = '' form['body_test'].label = '' form.helper = FormHelper() form.helper.layout = Layout( Row( Column('name', css_class='col-sm-8'), Column('type', css_class='col-sm-4'), css_class='form-row', ), TabHolder( Tab ('Body', Field('body', css_class='mt-2 tf-nowrap'), ), Tab ('Test', Field('body_test', css_class='mt-2 tf-nowrap'), Div( Submit('copy-from-body', 'Copy from Body'), Submit('copy-to-body', 'Copy to Body'), Submit('save-test', 'Save'), Button('show-test', 'Show'), css_class='text-right', ) ), ), FormActions( Submit('save', 'Save'), Button('delete', 'Delete'), Button('cancel', 'Cancel'), ) ) return form