我们从Python开源项目中,提取了以下15个代码示例,用于说明如何使用crispy_forms.layout.Div()。
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.disable_csrf = True self.helper.layout = Layout( Fieldset( 'Filter Pack', Div( Div(AppendedText('filter_pack_from', 'ft'), css_class='col-md-2'), Div(AppendedText('filter_pack_to', 'ft'), css_class='col-md-2'), Div(AppendedText('filter_pack_thickness', 'in'), css_class='col-md-2'), css_class='row', ), Div( Div('filter_pack_material', css_class='col-md-3'), Div('filter_pack_material_size', css_class='col-md-3'), css_class='row', ), ) ) super(ActivitySubmissionFilterPackForm, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.disable_csrf = True self.helper.layout = Layout( Fieldset( 'Water Quality', Div( Div('water_quality_characteristics', css_class='col-md-3'), css_class='row', ), Div( Div('water_quality_colour', css_class='col-md-3'), css_class='row', ), Div( Div('water_quality_odour', css_class='col-md-3'), css_class='row', ), ) ) super(ActivitySubmissionWaterQualityForm, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.disable_csrf = True self.helper.layout = Layout( Fieldset( 'General Comments', Div( Div('comments', css_class='col-md-12'), css_class='row', ), Div( Div('alternative_specs_submitted', css_class='col-md-12'), css_class='row', ), Div( Div(HTML('<p style="font-style: italic;">Declaration: By submitting this well construction, alteration or decommission report, as the case may be, I declare that it has been done in accordance with the requirements of the Water Sustainability Act and the Groundwater Protection Regulation.</p>'), css_class='col-md-12'), css_class='row', ), ) ) super(ActivitySubmissionCommentForm, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): super(SponsorPackageForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( Field("name"), Field("hpCatagoryName"), Field("comments"), Field("color"), AppendedText("price",u"€"), Field("countPackages"), Field("logoWebsitePositionEN"), Field("logoWebsitePositionDE"), Field("hasLogoOnPrintmedia"), Field("hasSocialMedia"), Field("hasHpText"), Field("hasProgramAdText"), Field("programAdTextNumWords"), Field("hasProgramAd"), Div( Field("programAdInfo"), Field("programAdInfoDescEN"), Field("programAdInfoDescDE"), HTML("<div class=\"form-grouper-label\">Program ad</div>"), css_class="form-grouper", css_id="program-ad-grouper"), Field("hasPackets"), Field("hasBooth"), Div( Field("boothPositionEN"), Field("boothPositionDE"), HTML("<div class=\"form-grouper-label\">Booth position</div>"), css_class="form-grouper", css_id="booth-grouper"), Field("hasRecruitingEvent"), Field("hasParticipants"), Field("numFreeTickets"), Field("additionalContentTextEN"), Field("additionalContentTextDE"), ) self.helper.add_input(Submit("Save", "Save"))
def __init__(self, *args, **kwargs): user = kwargs.pop('user', None) if user: kwargs.update(initial={ 'displayToUsers': [user.id,], 'submissionUser': user.id, }) super(AddPrivateEventForm,self).__init__(*args,**kwargs) self.fields['submissionUser'].widget = forms.HiddenInput() self.fields['status'].widget = forms.HiddenInput() self.fields['status'].initial = Event.RegStatus.hidden self.helper = FormHelper() self.helper.form_method = 'post' self.helper.form_tag = False # Our template must explicitly include the <form tag> self.helper.layout = Layout( 'status', 'submissionUser', 'title', Div( Field('category', wrapper_class='col'), Field('visibleTo', wrapper_class='col'), css_class='form-row'), Div('displayToUsers'), Div('displayToGroup'), Accordion( AccordionGroup(_('Add A Description'),'descriptionField',active=False), AccordionGroup(_('Add A Location'),Div('location','room','locationString')), AccordionGroup(_('Add a Link'),'link'), ), )
def __init__(self, *args, **kwargs): super(OccurrenceFormSetHelper, self).__init__(*args, **kwargs) self.form_tag = False # Our template must explicitly include the <form tag> self.layout = Layout( Div( Field('startTime', wrapper_class='col',), Field('endTime', wrapper_class='col',), Field('allDay', wrapper_class='col',), css_class='form-row' ), Div( Field('extraOccurrencesToAdd', wrapper_class='col',), Field('extraOccurrenceRule', wrapper_class='col',), css_class="form-row" ), Div( Field('sendReminderTo', wrapper_class='col',), Field('sendReminderWhen', wrapper_class='col',), Field('sendReminderWhich', wrapper_class='col',), css_class="form-row" ), Div('sendReminderGroup'), Div('sendReminderUsers'), Submit('submit', u'Submit', css_class='btn btn-primary'), )
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.disable_csrf = True self.helper.layout = Layout( Fieldset( 'Owner Information', Div( Div('owner_full_name', css_class='col-md-4'), css_class='row', ), Div( Div('owner_mailing_address', css_class='col-md-4'), css_class='row', ), Div( Div('owner_city', css_class='col-md-3 city'), Div('owner_province_state', css_class='col-md-1'), Div('owner_postal_code', css_class='col-md-3 postal'), css_class='row', ), ) ) super(WellOwnerForm, self).__init__(*args, **kwargs) # Make fields required on the form even though they are not required in the DB due to legacy data issues # TODO - check admin or staff user and don't make these fields required self.fields['owner_postal_code'].required = True # display code instead of the value from __str__ in the model self.fields['owner_province_state'].label_from_instance = self.label_from_instance_code try: bc = ProvinceState.objects.get(code='BC') self.initial['owner_province_state'] = bc self.fields['owner_province_state'].empty_label = None except Exception as e: pass
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.disable_csrf = True self.helper.render_hidden_fields = True self.helper.layout = Layout( Fieldset( 'Screen Information', Div( Div('screen_intake_method', css_class='col-md-2'), css_class='row', ), Div( Div('screen_type', css_class='col-md-2'), Div('screen_material', css_class='col-md-2'), Div('other_screen_material', css_class='col-md-3'), css_class='row', ), Div( Div('screen_opening', css_class='col-md-2'), Div('screen_bottom', css_class='col-md-2'), Div('other_screen_bottom', css_class='col-md-3'), css_class='row', ), ) ) super(ActivitySubmissionScreenIntakeForm, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.disable_csrf = True self.helper.layout = Layout( Fieldset( 'Well Yield Estimation', Div( Div('yield_estimation_method', css_class='col-md-3'), css_class='row', ), Div( Div(AppendedText('yield_estimation_rate', 'USgpm'), css_class='col-md-3'), Div(AppendedText('yield_estimation_duration', 'hrs'), css_class='col-md-3'), css_class='row', ), Div( Div(AppendedText('static_level', 'ft (btoc)'), css_class='col-md-3'), Div(AppendedText('drawdown', 'ft (btoc)'), css_class='col-md-3'), css_class='row', ), Div( Div(InlineRadios('hydro_fracturing_performed'), css_class='col-md-3'), Div(AppendedText('hydro_fracturing_yield_increase', 'USgpm'), css_class='col-md-3'), css_class='row', ), ) ) super(ProductionDataForm, self).__init__(*args, **kwargs)
def append_submit(self, label): btn = bootstrap.StrictButton(label, css_class='btn-primary', type="submit") if self.is_horizontal: self.append_field( layout.Div( layout.Div( btn, css_class=self._grid_class('label', offset=True) + self._grid_class('field')), css_class="form-group" ) ) else: self.append_field(btn)
def __init__(self, *args, **kwargs): super(FrontProfileForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_tag = False self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-4' self.helper.field_class = 'col-lg-8' self.helper.layout = Layout( # Div('picture', css_class='btn-file'), Fieldset("Details", 'institution', 'country', 'phone', 'picture'), Field('comment'), Div( Submit('delete_profile', 'Delete your account', css_class='btn-danger btn btn-md', type="submit", data_placement="left", data_toggle='confirmation'), Submit('update', 'Update', css_class="btn btn-md btn-primary center"), css_class='pull-right', style='margin-top:1%; margin-right:1%' ) )
def Section(title, *args): return Div( HTML(f'<h4 class="padtopmore padbottom">{title}</h4>'), *args )
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.disable_csrf = True self.helper.layout = Layout( Fieldset( 'Type of Work and Well Class', Div( Div('well_activity_type', css_class='col-md-4'), Div(HTML('<label for="units">Measurement units for data entry</label><br /><input type="radio" name="units" value="Imperial" checked /> Imperial<br /><input type="radio" name="units" value="Metric" disabled /> Metric<br /><br />'), css_class='col-md-4'), css_class='row', ), Div( Div('well_class', css_class='col-md-4'), Div(Div('well_subclass', id='divSubclass'), Div('intended_water_use', id='divIntendedWaterUse'), css_class='col-md-4'), css_class='row', ), Div( Div('identification_plate_number', css_class='col-md-4'), Div('well_plate_attached', css_class='col-md-4'), css_class='row', ), Div( Div('driller_responsible', css_class='col-md-4'), Div('driller_name', css_class='col-md-4'), Div(HTML('<input type="checkbox" id="chkSameAsPersonResponsible" /> <label for="chkSameAsPersonResponsible">Same as Person Responsible for Drilling</label>'), css_class='col-md-4'), css_class='row', ), Div( Div('consultant_name', css_class='col-md-4'), Div('consultant_company', css_class='col-md-4'), css_class='row', ), Div( Div('work_start_date', css_class='col-md-4 date'), Div('work_end_date', css_class='col-md-4 date'), css_class='row', ), ) ) super(ActivitySubmissionTypeAndClassForm, self).__init__(*args, **kwargs) try: con = WellActivityType.objects.get(code='CON') self.initial['well_activity_type'] = con self.fields['well_activity_type'].empty_label = None except Exception as e: pass
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.disable_csrf = True self.helper.render_hidden_fields = True self.helper.layout = Layout( Fieldset( 'Surface Seal and Backfill Information', Div( Div('surface_seal_material', css_class='col-md-3'), Div(AppendedText('surface_seal_depth', 'ft'), css_class='col-md-2'), Div(AppendedText('surface_seal_thickness', 'in'), css_class='col-md-2'), css_class='row', ), Div( Div('surface_seal_method', css_class='col-md-3'), css_class='row', ), Div( Div(HTML(' '), css_class='col-md-12'), css_class='row', ), Div( Div('backfill_above_surface_seal', css_class='col-md-3'), Div(AppendedText('backfill_above_surface_seal_depth', 'ft'), css_class='col-md-2'), css_class='row', ), ), Fieldset( 'Liner Information', Div( Div('liner_material', css_class='col-md-3'), css_class='row', ), Div( Div(AppendedText('liner_diameter', 'in'), css_class='col-md-2'), Div(AppendedText('liner_thickness', 'in'), css_class='col-md-2'), css_class='row', ), Div( Div(AppendedText('liner_from', 'ft (bgl)'), css_class='col-md-2'), Div(AppendedText('liner_to', 'ft (bgl)'), css_class='col-md-2'), css_class='row', ), ) ) super(ActivitySubmissionSurfaceSealForm, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_tag = False self.helper.disable_csrf = True self.helper.layout = Layout( Fieldset( 'Well Completion Details', Div( Div(AppendedText('total_depth_drilled', 'ft'), css_class='col-md-3'), Div(AppendedText('finished_well_depth', 'ft (bgl)'), css_class='col-md-3'), css_class='row', ), Div( Div(AppendedText('final_casing_stick_up', 'in'), css_class='col-md-3'), Div(AppendedText('bedrock_depth', 'ft (bgl)'), css_class='col-md-3'), css_class='row', ), Div( Div(AppendedText('static_water_level', 'ft (btoc)'), css_class='col-md-3'), Div(AppendedText('well_yield', 'USgpm'), css_class='col-md-3'), css_class='row', ), Div( Div(AppendedText('artesian_flow', 'USgpm'), css_class='col-md-3'), Div(AppendedText('artesian_pressure', 'ft'), css_class='col-md-3'), css_class='row', ), Div( Div('well_cap_type', css_class='col-md-3'), Div(InlineRadios('well_disinfected'), css_class='col-md-3'), css_class='row', ), ) ) super(WellCompletionForm, self).__init__(*args, **kwargs) # Make fields required on the form even though they are not required in the DB due to legacy data issues # TODO - check admin or staff user and don't make these fields required self.fields['total_depth_drilled'].required = True self.fields['finished_well_depth'].required = True # Make final casing stick up required for water supply well, injection well, recharge well, etc. if self.initial['well_class_code'] == 'WATR_SPPLY' or self.initial['well_class_code'] == 'INJECTION' or self.initial['well_class_code'] == 'RECHARGE': self.fields['final_casing_stick_up'].required = True