def __init__(self, project, request_user, *args, **kwargs): super(NewAnonymousMobileWorkerForm, self).__init__(*args, **kwargs) self.project = project self.request_user = request_user self.can_access_all_locations = request_user.has_permission( self.project.name, 'access_all_locations') if not self.can_access_all_locations: self.fields['location_id'].required = True if project.uses_locations: self.fields['location_id'].widget = AngularLocationSelectWidget( require=not self.can_access_all_locations) location_field = crispy.Field( 'location_id', ng_model='mobileWorker.location_id', ) else: location_field = crispy.Hidden( 'location_id', '', ng_model='mobileWorker.location_id', ) self.helper = FormHelper() self.helper.form_tag = False self.helper.label_class = 'col-sm-4' self.helper.field_class = 'col-sm-8' self.helper.layout = Layout( Fieldset( _('Basic Information'), crispy.Field( 'username', readonly=True, ), location_field, crispy.Hidden('is_anonymous', 'yes'), ))
def __init__(self, *args, **kwargs): super(DiscoveryForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = Layout( Field('match'), Field('file_format'), Field('name_template'), Field('base_file_template'), Field('new_base_template'), Field('language_regex'), Field('remove'), Div(template='addons/discovery_help.html'), ) if self.is_bound: # Perform form validation self.full_clean() # Show preview if form was submitted if self.cleaned_data['preview']: self.helper.layout.insert( 0, Field('confirm'), ) created, matched, deleted = self.discovery.perform( preview=True, remove=self.cleaned_data['remove'], ) self.helper.layout.insert( 0, ContextDiv( template='addons/discovery_preview.html', context={ 'matches_created': created, 'matches_matched': matched, 'matches_deleted': deleted, } ), )
def test_field_with_buttons(self, settings): form = SampleForm() form.helper = FormHelper() form.helper.layout = Layout( FieldWithButtons(Field('password1', css_class="span4"), StrictButton("Go!", css_id="go-button"), StrictButton("No!", css_class="extra"), StrictButton("Test", type="submit", name="whatever", value="something"), css_class="extra", autocomplete="off")) html = render_crispy_form(form) form_group_class = 'control-group' if settings.CRISPY_TEMPLATE_PACK in ('bootstrap3', 'bootstrap4'): form_group_class = 'form-group' assert html.count('class="%s extra"' % form_group_class) == 1 assert html.count('autocomplete="off"') == 1 assert html.count('class="span4') == 1 assert html.count('id="go-button"') == 1 assert html.count("Go!") == 1 assert html.count("No!") == 1 assert html.count('class="btn"') == 2 assert html.count('class="btn extra"') == 1 assert html.count('type="submit"') == 1 assert html.count('name="whatever"') == 1 assert html.count('value="something"') == 1 if settings.CRISPY_TEMPLATE_PACK == 'bootstrap': assert html.count('class="input-append"') == 1 elif settings.CRISPY_TEMPLATE_PACK == 'bootstrap3': assert html.count('class="input-group-btn') == 1 elif settings.CRISPY_TEMPLATE_PACK == 'bootstrap4': assert html.count('class="input-group-append') == 1
def __init__(self, *args, **kwargs): parent = kwargs.pop('parent', None) super(PageCreateForm, self).__init__(*args, **kwargs) self.fields['parent'].initial = parent 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', 'site', css_id='page-main'), Tab(_('Navigation'), 'in_navigation', 'parent', 'slug', 'override_url', 'redirect_to', 'symlinked_page'), Tab(_('Heading'), '_content_title', '_page_title', css_id='page-heading'), Tab( _('Publication'), 'active', 'featured', 'publication_date', 'publication_end_date', ), Tab(_('Theme'), 'template_key', 'layout', Fieldset('Themes', 'theme', *color_scheme_fields), css_id='page-theme-settings'), )) self.fields['color_scheme'].required = False
class SignupFormExtra(SignupForm): mobile = forms.CharField(label=_(u'手机号'),max_length=30,required=True) codesms = forms.CharField(label=_(u'手机验证码'),max_length=30,required=True) captcha = CaptchaField(label=_(u'验证码')) #contact = forms.CharField(label=_(u'Contact'),max_length=30,required=False) helper = FormHelper() helper.form_id = 'register_form' helper.form_action = '' helper.layout = Layout( Field('username',id='UserName'), Field('password1',id='LoginPass'), Field('password2',id='LoginPass2'), Field('mobile', id='Mobile'), PrependedText('codesms', '<a href="#" id="GetCode" disabled="disabled">点击获取验证码</a>',css_class='span1',id='SMS'), Field('email',id='Email'), Field('captcha'), FormActions( Submit('save_changes', u'注册', css_class="span2 btn-primary"), ) ) def clean(self): #多字段验证 cleaned_data=super(SignupFormExtra, self).clean() return cleaned_data def save(self): """ Override the save method to save the first and last name to the user field. """ # Original save method returns the user user = super(SignupFormExtra, self).save() return user
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = Layout( Fieldset( 'Summary', 'manufacturer', 'model', 'disambiguation', AppendedText('guide_number', 'm'), 'gn_info', AppendedText('trigger_voltage', 'V'), ), Fieldset( 'Features', 'pc_sync', 'hot_shoe', 'light_stand', 'manual_control', 'swivel_head', 'tilt_head', 'zoom', 'ttl', ), Fieldset( 'Power', 'battery_powered', 'battery_type', 'battery_qty', ), Fieldset( 'Meta', 'tags', 'image', 'image_attribution', 'image_attribution_link', ), FormActionButtons)
def __init__(self, document_type_pk=None, rating_decision_pk=None, issuer_pk=None, security_class=None, *args, **kwargs): """Initiate the class.""" super(RatingDecisionAddDocument, self).__init__(*args, **kwargs) self.helper = FormHelper(form=self) self.helper.layout = Layout( Div( Div(Field('upload'), css_class='col-md-12'), css_class='row', ), Field( 'security_class_id', type='hidden', value=security_class ), Field( 'document_type', type='hidden', value=document_type_pk ), Field( 'issuer', type='hidden', value=issuer_pk ), Field( 'rating_decision', type='hidden', value=rating_decision_pk ) )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'login100-form validate-form' self.helper.form_action = "/auth/register/" self.helper.form_id = "RegistrationForm" self.fields["username"].label = "Email Address" self.fields["username"].widget.attrs["type"] = "email" self.helper.attrs['onSubmit'] = "hashing(event)" fields = ["username", "password1", "password2"] for field in fields: self.fields[field].help_text = None self.helper.layout = Layout( Div( CustomInputField('username', css_class='input100', data_validate="Username is required", type="email", id='username'), CustomInputField( 'password1', css_class='input100', data_validate="Password must be 8 characters long", css_id='raw_password1'), CustomInputField( 'password2', css_class='input100', data_validate="Password must be same as above", css_id='raw_password2'), Div(Submit( 'Submit', 'Submit', css_class="login100-form-btn", css_id='login_submit', ), css_class="container-login100-form-btn")))
def __init__(self, content, *args, **kwargs): super(PublicationForm, self).__init__(*args, **kwargs) self.previous_page_url = content.get_absolute_url() self.helper = FormHelper() self.helper.form_action = reverse("validation:publish-opinion", kwargs={"pk": content.pk, "slug": content.slug}) self.helper.form_method = "post" self.helper.form_class = "modal modal-flex" self.helper.form_id = "valid-publication" self.no_subcategories = content.subcategory.count() == 0 no_category_msg = HTML( _( """<p><strong>Votre publication n'est dans aucune catégorie. Vous devez <a href="{}#{}">choisir une catégorie</a> avant de publier.</strong></p>""".format( reverse("content:edit", kwargs={"pk": content.pk, "slug": content.slug}), "div_id_subcategory" ) ) ) self.no_license = not content.licence no_license_msg = HTML( _( """<p><strong>Vous n'avez pas choisi de licence pour votre publication. Vous devez <a href="#edit-license" class="open-modal">choisir une licence</a> avant de publier.</strong></p>""" ) ) self.helper.layout = Layout( no_category_msg if self.no_subcategories else None, no_license_msg if self.no_license else None, HTML(_("<p>Ce billet sera publié directement et n'engage que vous.</p>")), StrictButton(_("Publier"), type="submit", css_class="btn-submit"), )
def __init__(self, *args, **kwargs): super(LayerForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( Fieldset(None, 'name', 'type', 'url', 'layer', 'attribution', 'description'), HTML( '<hr/><p><a class="btn" data-toggle="collapse" data-target="#more-options">extended form options »</a></p>' ), Fieldset( 'Advanced', 'image_format', # 'styles', 'refreshrate', 'transparent', # 'enable_identify', 'token', 'additional_domains', # 'constraints', # 'extent', # 'layer_parsing_function', # 'info_format', # 'root_field', # 'fields_to_show', 'downloadableLink', # 'spatial_reference', 'layer_params', 'dynamic_params', css_class='collapse', css_id='more-options', ), ButtonHolder( HTML('<hr/><p></p>'), Submit('Save', 'Save', css_class='button white btn'), ), )
class DeleteDrinksForm(forms.Form): helper = FormHelper() helper.form_class = "form-horizontal user-select" helper.layout = Layout( HTML( """<table class="table table-hover table-bordered"> <thead> <tr> <th>Select</th> <th>Drink</th> <th>Date</th> <th>Volume</th> <th>User</th> <th>Keg</th> </tr> </thead> <tbody> {% load kegweblib %} {% for drink in drinks %} <tr> <td><input type="checkbox" name="delete_ids[]" value="{{ drink.id }}"></td> <td> <div class="form-horizontal"> <a class="btn btn-small btn-primary" href="{% url "kb-drink" drink.id %}">Edit</a> <span>{{ drink.id }}</span> </td> <td>{{ drink.time }}</td> <td>{% volume drink.volume_ml %}</td> <td>{{ drink.user }}</td> <td>{{ drink.keg }}</td> </tr> {% endfor %} </tbody> </table>""" ), FormActions(Submit("delete_drinks", "Delete Drinks", css_class="btn-danger"),), )
def __init__(self, *args, **kwargs): super(ConfirmRegistrationForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'confirmation-form' self.helper.form_method = 'post' self.helper.form_action = 'register' self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-3' self.helper.field_class = 'col-lg-7' self.helper.layout = Layout( HTML(get_confirm_button_html()), Fieldset(_('Staff Actions'), Field('has_attended', data_off_text='No', data_on_text='Yes'), css_class='staff-actions'), Fieldset(_('Attendee Information'), 'first_name', 'last_name', Field('is_student', data_off_text='No', data_on_text='Yes', data_size='mini'), 'school', Field('food_restrictions', rows=1), 'tshirt_size', Field('is_returning', data_off_text='No', data_on_text='Yes', data_size='mini'), Field('is_first_time_hacker', data_off_text='No', data_on_text='Yes', data_size='mini'), css_class="attendee-info"), )
def __init__(self, user, *args, **kwargs): super(SMSDashboardForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_show_labels = False self.helper.form_class = 'well form-inline text-right' self.helper.layout = Layout( Div( Div('smscampaign', css_class='form-group'), Div('search_type', css_class='form-group'), Div(Submit('submit', _('search').title()), css_class='form-group'), ), ) # To get user's running campaign list if user: campaign_list = SMSCampaign.objects.filter( user=user).order_by('-id') campaign_choices = [(0, _('Select campaign'))] for cp in campaign_list: campaign_choices.append((cp.id, unicode(cp.name))) self.fields['smscampaign'].choices = campaign_choices
def __init__(self, *args, **kwargs): '''Extend Crispy Forms helper and layout objects. ''' super(ProfileForm, self).__init__(*args, **kwargs) self.fields["location"].queryset = School.objects.filter( organization=kwargs['instance'].organization).order_by('name') # Get the crispy helper and layout objects ready self.helper = FormHelper(self) self.helper.layout = Layout() self.helper.layout.append( DeepFriedForm(submit_text="Save Profile", cancel_url="/home/", cancel_text="Cancel")) self.helper.layout.insert( 0, # Index of layout items. HTML( '<div class="alert alert-block alert-danger">Choosing a building is required for making reservations.</div>' ), ) self.helper.form_tag = False
class BetaAccessForm(forms.Form): def clean_access_code(self): access_code_candidate = self.cleaned_data['access_code'] try: TinvilleUser.objects.get(access_code = access_code_candidate) except ObjectDoesNotExist: raise forms.ValidationError('Incorrect Access Code') return access_code_candidate access_code = forms.CharField(max_length=5) shop = forms.CharField(widget=forms.HiddenInput, required=False) helper = FormHelper() helper.form_show_labels = False helper.layout = Layout( Div( Field('access_code', placeholder="Beta Access Code"), HTML('<input type="hidden" name="shop" value="{{ shop }}">'), Submit('betaForm', 'Submit', css_class='btn btn-primary', style='margin-top: 10px') ) )
def __init__(self, *args, **kwargs): super(SalesConfigForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( TabHolder( Tab( 'Document Fields', 'default_invoice_comments', 'default_credit_note_comments', 'default_quotation_comments', 'default_terms', ), Tab( 'Page Layout', 'sales_tax', 'include_tax_in_invoice', 'next_invoice_number', 'next_quotation_number', 'include_units_in_sales_invoice', 'include_shipping_address', ))) self.helper.add_input(Submit('submit', "Submit"))
def __init__(self, *args, **kwargs): row1 = to_row([('tipo', 4), ('numero', 4), ('ano', 4)]) row2 = to_row([('data', 4), ('numero_protocolo', 4), ('ano_protocolo', 4)]) row3 = to_row([('assunto', 12)]) row4 = to_row([('interessado', 9), ('tramitacao', 3)]) row5 = to_row([('texto_integral', 12)]) row6 = to_row([('dias_prazo', 6), ('data_fim_prazo', 6)]) row7 = to_row([('observacao', 12)]) self.helper = FormHelper() self.helper.layout = Layout( Fieldset(_('Identificação Básica'), row1, row2, row3, row4, row5), Fieldset(_('Outras Informações'), row6, row7), form_actions(more=[Submit('Excluir', 'Excluir')]), ) super(DocumentoAdministrativoForm, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): super(DocumentoAdministrativoFilterSet, self).__init__(*args, **kwargs) local_atual = 'tramitacaoadministrativo__unidade_tramitacao_destino' self.filters['tipo'].label = 'Tipo de Documento' self.filters['tramitacaoadministrativo__status'].label = 'Situação' self.filters[local_atual].label = 'Localização Atual' row1 = to_row([('tipo', 6), ('numero', 6)]) row2 = to_row([('ano', 4), ('numero_protocolo', 4), ('data', 4)]) row3 = to_row([('interessado', 4), ('assunto', 4), ('tramitacao', 4)]) row4 = to_row([('tramitacaoadministrativo__unidade_tramitacao_destino', 6), ('tramitacaoadministrativo__status', 6)]) row5 = to_row([('o', 12)]) self.form.helper = FormHelper() self.form.helper.form_method = 'GET' self.form.helper.layout = Layout( Fieldset(_('Pesquisar Documento'), row1, row2, row3, row4, row5, form_actions(save_label='Pesquisar')))
class FooterPageAdminForm(forms.Form): body = forms.CharField(widget=forms.Textarea(attrs={ 'rows': 4, 'cols': 10 })) helper = FormHelper() helper.form_show_labels = False helper.layout = Layout( HTML( open_box_form('col-lg-12 col-md-12', _('Footer of each page of your site'))), HTML(""" <div> <p class="pull-right"> <a href="#" class="btn btn-success btn-sm" id="open-editor-btn"> Open Editor </a> </p> </div><br/><br/> <div class="embed-responsive" style="padding-bottom:20%"> <iframe id="body-iframe" name="body-iframe"></iframe> </div> <br><br> """), Field('body', rows="10", css_class='input-xlarge', id='body', type="hidden"), FormActions( Submit('save_changes', 'Save changes', css_class="btn-primary"), Submit('cancel', 'Cancel'), ), HTML(""" </div> </div> """), )
class EditKegForm(forms.ModelForm): class Meta: model = models.Keg fields = ('type', 'keg_type', 'full_volume_ml', 'spilled_ml', 'description', 'notes',) labels = { 'full_volume_ml': ('Full/Initial Volume'), 'spilled_ml': ('Spilled Volume'), } helper = FormHelper() helper.form_class = 'form-horizontal' helper.layout = Layout( Field('type', css_class='input-block-level', rows='3'), Field('keg_type', css_class='input-block-level', rows='3'), Field('full_volume_ml', css_class='input-volume'), Field('spilled_ml', css_class='input-volume'), Field('description', css_class='input-block-level', rows='3'), Field('notes', css_class='input-block-level', rows='3'), FormActions( Submit('submit_edit_keg', 'Save Keg', css_class='btn-primary'), HTML("""<a href="#cancelModal" role="button" class="btn btn-danger" data-toggle="modal"> <i class="icon-trash icon-white"></i> Permanently Delete</a>""") ) )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.form_action = 'accounts:generate_class_list' self.helper.form_id = 'generate-class-list-form' self.helper.layout = Layout( Fieldset( 'Filter Tags', HTML(''' {% include '_messages.html' %} '''), Div( Field('form', wrapper_class='col'), Field('stream_name', wrapper_class='col'), css_class='form-row', ), Div( Field('file_type', wrapper_class='col'), css_class='form-row', ), Submit('submit', 'Generate', css_class='btn btn-primary'), css_class='border rounded p-3', ))
def __init__(self, *args, **kwargs): super(ViewShareRegistrationForm, self).__init__(*args, **kwargs) org_types = models.OrganizationType.objects.all().order_by("value") self.org_type_choices = json.dumps([b.value for b in org_types]) # self.fields["username"].regex = r"^[\w.-_]+$" self.helper = FormHelper() self.helper.layout = Layout( Fieldset("User Information", "username", "email", "password1", "password2", css_class="inlineLabels"), Fieldset("Describe your Organization", "organization", "org_type", "org_state", css_class="inlineLabels"), Fieldset("How do you plan to use %s?" % settings.SITE_NAME, "reason", css_class="inlineLabels")) self.helper.add_input(Submit('add', "Sign Up"))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['image'].required = False self.fields['description'].widget.attrs.update( {'placeholder': 'mô tả thông tin khuyến mãi'}) self.fields['name'].widget.attrs.update( {'placeholder': _('promotion')}), self.fields['start_at'] = forms.DateField( label=_('start time').capitalize(), widget=forms.TextInput(attrs={ 'placeholder': _('Please enter the value'), 'class': 'form-control', 'autoComplete': "off" }, ), required=False, ) self.fields['end_at'] = forms.DateField( label=_('end time').capitalize(), widget=forms.TextInput(attrs={ 'placeholder': _('Please enter the value'), 'class': 'form-control', 'autoComplete': "off" }, ), required=False, ) self.helper = FormHelper() self.helper.form_show_errors = True self.helper.layout = Layout( 'name', 'image', 'description', 'content', Row(Column('start_at', css_class='form-group col-md-4 mb-0'), Column('end_at', css_class='form-group col-md-4 mb-0'), css_class='form-row'), Fieldset(_('Promotion type'), Formset('promotion_types')), Submit('submit', _('Save'), css_class='btn-success'))
def get_form(self, form_class=None): form = super(ExercisesEditAddView, self).get_form(form_class) exercise = self.get_form_kwargs()['instance'] if exercise is not None: form.fields['category'].initial = exercise.exercise_base.category form.fields[ 'equipment'].initial = exercise.exercise_base.equipment.all() form.fields[ 'muscles'].initial = exercise.exercise_base.muscles.all() form.fields['muscles_secondary'].initial = \ exercise.exercise_base.muscles_secondary.all() form.helper.layout = Layout( "name_original", "description", "category", "equipment", Row(Column('muscles', css_class='form-group col-6 mb-0'), Column('muscles_secondary', css_class='form-group col-6 mb-0'), css_class='form-row'), Row(Column('license', css_class='form-group col-6 mb-0'), Column('license_author', css_class='form-group col-6 mb-0'), css_class='form-row'), ) return form
def __init__(self, *args, **kwargs): """ All of the custom logic in this form is to handle the professor verification flow: - show a "Request Professor Verification" checkbox by default - if checked, switch the checkbox to a "Professor Verification Requested" message and send admins an email - if an admin sets verified_professor=True, change the message to "Verified Professor" """ self.request = kwargs.pop("request", None) super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_tag = True self.helper.layout = Layout( 'email_address', 'attribution', 'affiliation', (HTML( '<div class="verified-professor">Verified Professor<span class="verified"></span></div>' ) if self.instance.verified_professor else HTML( '<div class="verified-professor">Professor Verification Requested</div>' ) if self.instance.professor_verification_requested else 'professor_verification_requested'), Submit('submit', 'Save changes'), HTML( '<a href="%s" class="btn btn-default">Change your password</a>' % reverse('password_change')), ) if self.instance.professor_verification_requested or self.instance.verified_professor: self.fields.pop('professor_verification_requested') else: self.fields[ 'professor_verification_requested'].label = 'Request Professor Verification' fix_after_rails( "setting email_address.required to True manually until the field is required in the model" ) self.fields['email_address'].required = True
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'GET' self.helper.disable_csrf = True self.fields['buscar'].label = '' self.fields['items'].label = '' self.fields['items'].widget = SelectLiveSearchInput( choices=ITEMS_X_PAG) self.fields['modo'].widget.attrs['hidden'] = True self.fields['modo'].label = "" for field_name, field in self.fields.items(): field.widget.attrs['class'] = 'form-control-sm' self.helper.layout = Layout( Row( Column('buscar', css_class='form-group col-md-5 mb-0 '), FieldWithButtons('items', boton_buscar(), css_class='form-group col-md-2 mb-0'), ), 'modo', )
def __init__(self, *args, **kwargs): super(SuggestionForm, self).__init__(*args, **kwargs) # Translators: This labels a textfield where users can enter the name of the potential partner they'll suggest self.fields["suggested_company_name"].label = _( "Name of the potential partner") # Translators: This labels a textfield where users can enter the description of the potential partner they'll suggest self.fields["description"].label = _("Description") # Translators: This labels a textfield where users can enter the website URL of the potential partner they'll suggest self.fields["company_url"].label = _("Website") # @TODO: This sort of gets repeated in PartnerSuggestionView. # We could probably be factored out to a common place for DRYness. 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-7" self.helper.layout = Layout( "suggested_company_name", "description", "company_url", "next", # Translators: This labels a button which users click to submit their suggestion. Submit("submit", _("Submit"), css_class="center-block"), )
def __init__(self, *args, **kwargs): #self.user = kwargs.pop('user') super(WoSummaryReportForm, self).__init__(*args, **kwargs) catDict = {} for cat in CategoryAction.objects.all(): catDict[cat.name] = cat.name #add one more for Incoming catDict['Incoming'] = 'Incoming' # Converting into list of tuple catlist = list(catDict.items()) self.fields['wo_category'].widget = Select(choices=catlist) self.helper = FormHelper() self.helper.form_method = 'get' self.helper.layout = Layout( Row(Column('start_date', css_class='form-group col-md-2 mb-0'), Column('end_date', css_class='form-group col-md-2 mb-0'), css_class='form-row'), Field('wo_category', css_class='form-group col-md-2 mb-0'), Submit('submit', 'Submit'))
def __init__(self, *args, **kwargs): super(SignupExtraForm, self).__init__(*args, **kwargs) self.helper = horizontal_form_helper() self.helper.form_tag = False self.helper.layout = Layout( 'shift_type', 'total_work', indented_without_label('overseer'), Fieldset( 'Työtodistus', indented_without_label('want_certificate'), 'certificate_delivery_address', ), Fieldset( 'Lisätiedot', 'shirt_size', 'special_diet', 'special_diet_other', 'lodging_needs', 'prior_experience', 'shift_wishes', 'free_text', ), )
def __init__(self, *args, **kwargs): super(ContestForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.form_method = 'POST' self.helper.form_action = reverse('contest:create_contest') self.helper.layout = Layout( Div(Field( 'title', css_class='form-control', ), Field( 'start_datetime', css_class='form-control datetime-field', ), Field( 'end_datetime', css_class='form-control datetime-field', ), HTML( '<p><strong>Note that after submitting your contest, you must add problems to it</strong></p>', ), ButtonHolder(Submit('submit', 'Submit'), ), css_class='form-group'), )