def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_method = 'post' self.request = kwargs.pop('request') self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-sm-2' self.helper.field_class = 'col-sm-6' self.helper.form_error_title = 'Form Errors' self.helper.error_text_inline = True self.helper.help_text_inline = True self.helper.html5_required = True self.helper.layout = Layout( HTML("""<br/>"""), 'name', 'url', Field('description', rows="3", css_class='input-xlarge'),'file_field', 'project','program', FormActions( Submit('submit', 'Save', css_class='btn-default'), Reset('reset', 'Reset', css_class='btn-warning') ) ) super(DocumentationForm, self).__init__(*args, **kwargs) #override the program queryset to use request.user for country countries = getCountry(self.request.user) self.fields['project'].queryset = ProjectAgreement.objects.filter(program__country__in=countries) self.fields['program'].queryset = Program.objects.filter(country__in=countries)
class RegistrationForm(UserChangeForm): """ Form for registering a new account. """ def __init__(self, *args, **kwargs): user = kwargs.pop('initial') super(RegistrationForm, self).__init__(*args, **kwargs) del self.fields['password'] print user['username'].is_superuser # if they aren't a super user or User Admin don't let them change countries form field if 'User Admin' not in user['username'].groups.values_list('name', flat=True) and not user['username'].is_superuser: self.fields['countries'].widget.attrs['disabled'] = "disabled" self.fields['country'].widget.attrs['disabled'] = "disabled" class Meta: model = TolaUser fields = '__all__' helper = FormHelper() helper.form_method = 'post' helper.form_class = 'form-horizontal' helper.label_class = 'col-sm-2' helper.field_class = 'col-sm-6' helper.form_error_title = 'Form Errors' helper.error_text_inline = True helper.help_text_inline = True helper.html5_required = True helper.layout = Layout(Fieldset('','title', 'name', 'employee_number', 'user', 'username', 'country', 'countries','modified_by','created','updated'), Submit('submit', 'Submit', css_class='btn-default'), Reset('reset', 'Reset', css_class='btn-warning'))
def test_inputs(settings): form_helper = FormHelper() form_helper.add_input(Submit('my-submit', 'Submit', css_class="button white")) form_helper.add_input(Reset('my-reset', 'Reset')) form_helper.add_input(Hidden('my-hidden', 'Hidden')) form_helper.add_input(Button('my-button', 'Button')) template = get_template_from_string(""" {% load crispy_forms_tags %} {% crispy form form_helper %} """) c = Context({'form': TestForm(), 'form_helper': form_helper}) html = template.render(c) assert 'button white' in html assert 'id="submit-id-my-submit"' in html assert 'id="reset-id-my-reset"' in html assert 'name="my-hidden"' in html assert 'id="button-id-my-button"' in html if settings.CRISPY_TEMPLATE_PACK == 'uni_form': assert 'submit submitButton' in html assert 'reset resetButton' in html assert 'class="button"' in html else: assert 'class="btn"' in html assert 'btn btn-primary' in html assert 'btn btn-inverse' in html assert len(re.findall(r'<input[^>]+> <', html)) == 8
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if 'date' in self.fields: today = datetime.today() max_date = today + relativedelta(months=1) max_date = max_date.replace(day=14) max_year = today.year + 1 if today.month == 12 and today.day >= 15: max_year += 1 years = range(1999, max_year) self.fields['date'].widget = forms.SelectDateWidget(years=years) self.fields['date'].widget = forms.TextInput( attrs={ 'type': 'date', 'pattern': '\d{4}-\d{2}-\d{2}', 'min': '1999-05-07', 'max': max_date.strftime('%Y-%m-%d') } ) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.layout = Layout( Row( Column('credit_amount', css_class='form-group col-md-6 col-sm-12 '), Column('credit_term', css_class='form-group col-md-6 col-sm-12 ') ), Row( Column('overdue_days', css_class='form-group col-md-6 col-sm-12'), Column('date', css_class='form-group col-md-6 col-sm-12') ), Submit('submit', _('Query')), Reset('reset', _('Reset')), )
def __init__(self, *args, **kwargs): self.request = kwargs.pop('request') self.current_objective = kwargs.pop('current_objective') self.helper = FormHelper() self.helper.form_method = 'post' self.helper.form_error_title = 'Form Errors' self.helper.error_text_inline = True self.helper.help_text_inline = True self.helper.html5_required = True self.helper.form_tag = True self.helper.layout = Layout( Row( Column('name', css_class='form-group col-md-12 mb-0'), css_class='form-row' ), Row( Column('parent', css_class='form-group col-md-6 mb-0'), Column('program', css_class='form-group col-md-6 mb-0'), css_class='form-row' ), Row( Column('description', css_class='form-group col-md-12 mb-0'), css_class='form-row' ), Reset('reset', 'Close', css_class='btn-md btn-close'), Submit('submit', 'Save Changes', css_class='btn-md btn-success'), ) super(ObjectiveForm, self).__init__(*args, **kwargs) self.fields['parent'].queryset = Objective.objects.\ filter(program__organization=self.request.user.activity_user.organization).\ exclude(pk=self.current_objective.id)
def __init__(self, *args, **kwargs): super(TextBasedInputFieldsForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.form_action = reverse('portfolio:django_forms', args=('html5-input-types', )) self.helper.form_show_labels = False self.helper.layout = Layout( HTML( _("<h4><em>HTML5 input types.</em></h4><p>"If your form includes an URLField, an EmailField or any integer field type, Django will use the url, email and number HTML5 input types. By default, browsers may apply their own validation on these fields, which may be stricter than Django’s validation. If you would like to disable this behavior, set the <strong>novalidate</strong> attribute on the form tag, or specify a different widget on the field, like TextInput" (<a href='https://docs.djangoproject.com/en/1.10/topics/forms/#working-with-forms' target='_blank'>Django Documentation <span class='glyphicon glyphicon-new-window' aria-hidden='true'></span></a>)</p><p>Browsers apply their own validation on these fields. For any integer field <strong>Field.localize</strong> must be <strong>False</strong>. Try to input the wrong value and submit the form - browser validation will warn you about an error in the first wrong field.</p>" )), PrependedText('my_url', 'URLField', placeholder=_("valid URL")), PrependedText('my_email', 'EmailField', placeholder=_("valid Email")), PrependedText( 'integer', 'IntegerField', placeholder=_("integer between 10 and 100 - required")), PrependedText('my_float', 'FloatField', placeholder=_("float between 1.44 and 3.14")), PrependedText( 'my_decimal', 'DecimalField', placeholder=_("digits: 6, decimal places: 2 == 1234.56")), FormActions( Submit('submit', _('Submit'), css_class='button white'), Reset('reset', _('Reset'))))
class RegistrationForm(UserChangeForm): """ Form for registering a new account. """ def __init__(self, *args, **kwargs): super(RegistrationForm, self).__init__(*args, **kwargs) del self.fields['password'] class Meta: model = UserProfile fields = '__all__' helper = FormHelper() helper.form_method = 'post' helper.form_class = 'form-horizontal' helper.label_class = 'col-sm-2' helper.field_class = 'col-sm-6' helper.form_error_title = 'Form Errors' helper.error_text_inline = True helper.help_text_inline = True helper.html5_required = True helper.layout = Layout( Fieldset('', 'title', 'name', 'employee_number', 'user', 'username', 'country', 'countries', 'modified_by', 'created', 'updated'), Submit('submit', 'Submit', css_class='btn-default'), Reset('reset', 'Reset', css_class='btn-warning'))
def __init__(self, user=None, *args, **kwargs): self.helper = FormHelper() self.helper.form_id = 'id-new_item_form' self.helper.form_method = 'post' self.helper.form_action = 'new_item' self.helper.form_class = 'form-horizontal' #self.helper.help_text_inline = True self.helper.layout = Layout( Field('name'), Field('university'), Field('category'), Field('description'), Field('location'), Field('expire_date'), Field('quantity'), Field('quantity_type'), Field('sell_individually'), Field('swappable'), Field('price', help_text_inline=True), #AppendedText('price', '£'), #Needs investigation. Field('notes'), FormActions(Reset('reset', 'Reset'), Submit('submit', 'Add Item', css_class="btn-primary"))) self.user = user super(ItemForm, self).__init__(*args, **kwargs)
class TeacherForm(forms.ModelForm): helper = FormHelper() helper.form_tag = False helper.form_method = 'post' helper.layout = Layout( HTML(u"<p class=\"text-primary\">请如实填写以下注册信息:</p>"), Row(Div('realName', css_class="col-md-4")), Row( Div('loginName', css_class="col-md-4"), Div('projectAccount', css_class="col-md-6 col-md-offset-1") ), Row( Div('email', css_class="col-md-4"), Div('phone', css_class="col-md-4 col-md-offset-1") ), Row( Div(Field('organization', css_class="select-primary select-block mbl"), css_class="col-md-4"), ), 'story', #FormActions for bootstrap only FormActions( Submit('save_changes', _(u'提交'), css_class="btn-primary"), Reset('reset', _(u'重置')), ) ) class Meta: model = EmployeeUser
def __init__(self, *args, **kwargs): super(WorkManualform, self).__init__(*args, **kwargs) self.fields[ 'audit_typ'].label_from_instance = lambda obj: "%s" % obj.audittype self.helper = FormHelper() self.helper.add_input( Submit('submit', 'Submit', css_class='btn-success')) self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-2' self.helper.layout = Layout( Div( Field('audit_typ'), Field('cls_ref_no'), Field('activity_title'), Field('ISO_certification_year'), Field('type_of_projectortender'), # Fieldset('Add titles'), Field('checklist'), Formset('activity'), ButtonHolder( Submit('submit', 'Submit', css_class='btn-success'), Reset('reset', 'Reset', css_class='btn-success'), HTML( """<a class= "btn btn-success" href= "{% url 'QMS:workmanualview' %}"> Back</a>""" ))))
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.html5_required = True self.helper.form_id = "filter_form" self.helper.form_show_labels = False self.helper.layout = Layout( # set custom id for country becasue of javascript # reuse of default id Field('country', css_class="input-sm", id="countries"), Field('program', css_class="input-sm"), Field('sector', css_class='input-sm'), # Field('start_date', css_class='input-sm'), # Field('end_date', css_class='input-sm'), ) self.helper.form_method = 'get' self.helper.form_action = '/reports/report/' self.helper.add_input( Submit('submit', 'Submit', css_class='btn-success btn-sm')) self.helper.add_input( Reset('reset', 'Reset', css_id='id_search_form_reset_btn', css_class='btn-warning btn-sm')) super(FilterForm, self).__init__(*args, **kwargs)
class LoginForm(AuthenticationForm): helper = FormHelper() helper.form_method = "POST" helper.form_action = '' helper.layout = Layout( Fieldset( 'User Login', 'username', 'password', ), FormActions( Submit('submit', 'Login', css_class='btn btn-primary'), Reset('reset', 'Clear', css_class='btn btn-default'), )) class Meta: model = User fields = ['username', 'password'] widgets = { 'username': forms.EmailInput, } def __init__(self, *args, **kwargs): super(LoginForm, self).__init__(*args, **kwargs) self.fields['username'].label = "Email Address"
class BookmarkForm(forms.ModelForm): """ Form for registering a new account. """ class Meta: model = TolaBookmarks fields = ['name', 'bookmark_url'] def __init__(self, *args, **kwargs): super(BookmarkForm, self).__init__(*args, **kwargs) helper = FormHelper() helper.form_method = 'post' helper.form_class = 'form-horizontal' helper.label_class = 'col-sm-2' helper.field_class = 'col-sm-6' helper.form_error_title = 'Form Errors' helper.error_text_inline = True helper.help_text_inline = True helper.html5_required = True helper.form_tag = True helper.layout = Layout( Fieldset('', 'name', 'bookmark_url'), Submit('submit', _('Submit'), css_class='btn-default'), Reset('reset', _('Reset'), css_class='btn-warning'))
class ProfileUpdateForm(forms.ModelForm): """ Form for registering a new account. """ def __init__(self, *args, **kwargs): user = kwargs.pop('user') super(ProfileUpdateForm, self).__init__(*args, **kwargs) class Meta: model = TolaUser fields = [ 'language', ] helper = FormHelper() helper.form_method = 'post' helper.form_class = 'hide-askerisks' helper.label_class = '' helper.field_class = '' helper.form_error_title = _('Form Errors') helper.error_text_inline = True helper.help_text_inline = True helper.html5_required = True helper.layout = Layout( Field('language'), Div( FormActions(Submit('submit', _('Save changes'), css_class=''), Reset('reset', _('Cancel'), css_class='')), ), )
def __init__(self, *args, **kwargs): super(DateTimeDjangoFieldsForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.form_action = reverse('portfolio:django_forms', args=('date-time-fields', )) self.helper.form_show_labels = False self.helper.layout = Layout( HTML( _("<h4><em>Time and Date Django fields.</em></h4><p>Django uses <strong>TextInput</strong> as a default widget for date and time fields, so only <em>required</em>, <em>max_length</em> and <em>min_length</em> properties are validated by browsers. Try to input the wrong value and submit the form - browser validation will not warn you about an error and you will get a Django validation error.</p><p>Each field accepts <strong>format</strong> optional argument. If no format argument is provided the first format found in DATE(TIME)_INPUT_FORMATS settings will be used.</p>" )), PrependedText('my_time', 'TimeField', placeholder=_("14:30:59 or 14:30")), PrependedText( 'my_datetime', 'DateTimeField', placeholder=_("2006-10-25 14:30:59 (YYYY-MM-DD HH:MM:SS)")), PrependedText('my_date', 'DateField', placeholder=_("2017-03-19 (YYYY-MM-DD)")), PrependedText('my_duration', 'DurationField', placeholder="1 12:32:44"), FormActions( Submit('submit', _('Submit'), css_class='button white'), Reset('reset', _('Reset'))))
def test_inputs(self): form_helper = FormHelper() form_helper.add_input( Submit('my-submit', 'Submit', css_class="button white")) form_helper.add_input(Reset('my-reset', 'Reset')) form_helper.add_input(Hidden('my-hidden', 'Hidden')) form_helper.add_input(Button('my-button', 'Button')) template = loader.get_template_from_string(u""" {% load crispy_forms_tags %} {% crispy form form_helper %} """) c = Context({'form': TestForm(), 'form_helper': form_helper}) html = template.render(c) self.assertTrue('button white' in html) self.assertTrue('id="submit-id-my-submit"' in html) self.assertTrue('id="reset-id-my-reset"' in html) self.assertTrue('name="my-hidden"' in html) self.assertTrue('id="button-id-my-button"' in html) if self.current_template_pack == 'uni_form': self.assertTrue('submit submitButton' in html) self.assertTrue('reset resetButton' in html) self.assertTrue('class="button"' in html) else: self.assertTrue('class="btn"' in html) self.assertTrue('btn btn-primary' in html) self.assertTrue('btn btn-inverse' in html) self.assertEqual(len(re.findall(r'<input[^>]+> <', html)), 8)
def __init__(self, *args, **kwargs): super(TextInputFieldsForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_show_labels = False self.helper.form_method = 'post' self.helper.form_action = reverse('portfolio:django_forms', args=('text-input', )) self.helper.layout = Layout( HTML( _("<h4><em>TextInput based fields.</em></h4><p>These Django fields use <strong>TextInput</strong> as a default widget, so only <em>required</em>, <em>max_length</em> and <em>min_length</em> properties are validated by browsers. Try to input the wrong value and submit the form - browser validation will not warn you about an error and you will get a Django validation error.</p><div class='panel panel-info'><div class='panel-body'>All <a href='{% url 'portfolio:django_forms' 'date-time-fields' %}'>time and date</a> Django fields use text inputs.</div></div>" )), PrependedText('your_name', 'CharField', placeholder=_("any char or sign")), PrependedText( 'my_slug', 'SlugField', placeholder=_( "only letters, numbers, underscores, and hyphens")), PrependedText('ip', 'GenericIPAddressField', placeholder="127.0.0.1"), PrependedText('my_regex', 'RegexField', placeholder=_("string with \"foo\" substring")), PrependedText('my_uuid', 'UUIDField', placeholder="64e5e068-eaf7-4009-84f5-72bd21963032"), FormActions( Submit('submit', _('Submit'), css_class='button white'), Reset('reset', _('Reset'))))
class UpdateLanguageForm(forms.ModelForm): """ Update language form """ def __init__(self, *args, **kwargs): super(UpdateLanguageForm, self).__init__(*args, **kwargs) class Meta: model = Language fields = '__all__' helper = FormHelper() helper.form_method = 'POST' helper.form_class = 'dynamic-form' helper.layout = Layout( Div( Field('locale_id', css_class='form-control', readonly=True), Field('lang_name', css_class='form-control'), Field('locale_script', css_class='form-control'), Field('locale_alias', css_class='form-control'), Field('lang_status', css_class='bootstrap-switch'), FormActions(Submit('updateLanguage', 'Update Language'), Reset('reset', 'Reset', css_class='btn-danger')))) def clean_locale_id(self): """ Set the original value of locale_id even if POST has new value. Retrieves value from instance of Languages being updated. If it's None, then returns the value entered by user. """ locale_id = getattr(self.instance, 'locale_id', None) if locale_id: return locale_id else: return self.cleaned_data.get('locale_id', None)
class FeedbackForm(forms.ModelForm): class Meta: model = Feedback fields = '__all__' severity = forms.ChoiceField( label="Priority", choices=(("High", "High"), ("Medium", "Medium"), ("Low", "Low")), widget=forms.Select, initial='2', required=True, ) helper = FormHelper() helper.form_method = 'post' helper.form_class = 'form-horizontal' helper.label_class = 'col-sm-2' helper.field_class = 'col-sm-6' helper.form_error_title = 'Form Errors' helper.error_text_inline = True helper.help_text_inline = True helper.html5_required = True helper.layout = Layout( Fieldset('', 'submitter', 'note', 'page', 'severity'), Submit('submit', 'Submit', css_class='btn-default'), Reset('reset', 'Reset', css_class='btn-warning'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_action = '' self.fields["cysbond"].validators.append(validators.validate_cysbond) self.fields["temperatures"].validators.append( validators.validate_temps) self.fields["cysbond"].widget.attrs["placeholder"] = "e.g. 1:99,35:150" self.fields["temperatures"].widget.attrs[ "placeholder"] = "e.g. 298,300" self.helper.layout = Layout( Fieldset( "Q Ligand FEP run parameters", Div(Div("forcefield", css_class="col-sm-6"), Div("sampling", css_class="col-sm-6"), css_class="row"), Div(Div("cysbond", css_class="col-sm-6"), Div("windows", css_class="col-sm-6"), css_class="row"), Div(Div("system", css_class="col-sm-6"), Div("temperatures", css_class="col-sm-6"), css_class="row"), Div(Div("replicates", css_class="col-sm-4"), Div("start", css_class="col-sm-4"), Div("sphere_radius", css_class="col-sm-4"), css_class="row")), ButtonHolder(Submit("submit", "Submit", css_class="bg-cp1"), Reset("reset", "Reset")))
def __init__(self, *args, **kwargs): super(UniSearchForm, self).__init__(*args, **kwargs) #self.fields['general_search'].widget = HiddenInput() # because we want the search box up top, so we copy the value from that box to this hidden one prior to submission #self.fields['geometry_type'].widget = HiddenInput() # because we need to indicate we are looking for centroid points self.helper = FormHelper() self.helper.form_id = 'UniSearchForm' self.helper.form_class = 'form-inline' #self.helper.label_class = 'col-sm-3' #self.helper.field_class = 'col-sm-5' self.helper.render_unmentioned_fields = False self.helper.form_method = 'get' self.helper.form_action = '' self.helper.layout = Layout( Field('parcel_or_street_address'), Field('mortgage_decision'), Field('bid_group_filter', css_class='input-sm'), Field('mva_category_filter', css_class='input-sm'), Field('adjacent_homesteads_non_surplus_filter', css_class='input-sm'), Field('ilp_within_quarter_mile_filter', css_class='input-sm'), FormActions( Reset('cancel', 'Reset'), Submit('submit', 'Search', css_class='top-search-button'), #HTML('<button id="modal_toggle" class="btn btn-info btn-modal" data-toggle="modal" data-target="#fsModal">Show Results Table</button>'), ), # Field('township', css_class='input-sm'), )
def __init__(self, *args, **kwargs): super(UpdatePropertyForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( Row(Column('monthly_rent', css_class="form-group col-md-6 mb-0 col-lg-2"), Column('area', css_class="form-group col-md-6 mb-0 col-lg-2"), css_class='form-row'), Row(Column('property_image', css_class="form-group col-md-6 mb-6 col-lg-5"), css_class='form-row'), Row(Column('address_line_1', css_class="form-group col-md-9 mb-6 col-lg-5"), css_class='form-row'), Row(Column('address_line_2', css_class="form-group col-md-9 mb-6 col-lg-5"), css_class='form-row'), Row(Column( Submit('submit', 'Submit', css_class='col-lg-2 btn-success btn-border'), Reset('reset', 'Reset', css_class='col-lg-2 btn-primary btn-border')), css_class='form-row'))
def test_inputs(settings): form_helper = FormHelper() form_helper.add_input( Submit("my-submit", "Submit", css_class="button white")) form_helper.add_input(Reset("my-reset", "Reset")) form_helper.add_input(Hidden("my-hidden", "Hidden")) form_helper.add_input(Button("my-button", "Button")) template = Template(""" {% load crispy_forms_tags %} {% crispy form form_helper %} """) c = Context({"form": SampleForm(), "form_helper": form_helper}) html = template.render(c) assert "button white" in html assert 'id="submit-id-my-submit"' in html assert 'id="reset-id-my-reset"' in html assert 'name="my-hidden"' in html assert 'id="button-id-my-button"' in html if settings.CRISPY_TEMPLATE_PACK == "uni_form": assert "submit submitButton" in html assert "reset resetButton" in html assert 'class="button"' in html else: assert 'class="btn"' in html assert "btn btn-primary" in html assert "btn btn-inverse" in html if settings.CRISPY_TEMPLATE_PACK == "bootstrap4": assert len(re.findall(r"<input[^>]+> <", html)) == 9 else: assert len(re.findall(r"<input[^>]+> <", html)) == 8
def test_inputs(self): form_helper = FormHelper() submit = Submit('my-submit', 'Submit', css_class="button white") reset = Reset('my-reset', 'Reset') hidden = Hidden('my-hidden', 'Hidden') button = Button('my-button', 'Button') form_helper.add_input(submit) form_helper.add_input(reset) form_helper.add_input(hidden) form_helper.add_input(button) template = get_template_from_string(u""" {% load crispy_forms_tags %} {% crispy form form_helper %} """) c = Context({'form': TestForm(), 'form_helper': form_helper}) html = template.render(c) self.assertTrue('button white' in html) self.assertTrue('submit submitButton' in html or 'btn' in html) self.assertTrue('id="submit-id-my-submit"' in html) self.assertTrue('reset resetButton' in html) self.assertTrue('id="reset-id-my-reset"' in html) self.assertTrue('name="my-hidden"' in html) self.assertTrue('button' in html) self.assertTrue('id="button-id-my-button"' in html)
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.form_action = 'account_signup' self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-sm-2' self.helper.field_class = 'col-sm-8' self.helper.layout = Layout( Field('first_name', 'last_name'), PrependedText('email', '<i class="fa fa-envelope-o fa-fw"></i>'), PrependedText('username', '<i class="fa fa-user fa-fw"></i>'), PrependedText('password1', '<i class="fa fa-key fa-fw"></i>'), PrependedText('password2', '<i class="fa fa-key fa-fw"></i>'), Fieldset( _('Responsable scientifique'), 'mentor', Field('willing_to_be_mentor'), 'groups', ), Field('next'), FormActions( Submit('save_changes', _('Enregistrer')), Reset('reset', _('Réinitialiser'), css_class='btn-default'), css_class='row', ), ) super(HierarchicUserSignupForm, self).__init__(*args, **kwargs)
def __init__(self, owner, user=None, submit_text=_('Create'), *args, **kwargs): super().__init__(*args, **kwargs) self.user = user self.owner = owner self.helper = FormHelper(self) self.helper.layout = Layout( Row(Column(Field('name', placeholder='Middle-Earth, Narnia, Argos...'), css_class='col-12 col-lg-7'), Column(Field( 'description', placeholder= _('Write something about your world, its civilizations, its culture...' )), css_class='col-12 col-lg-7'), Column(Field('image'), css_class='col-12 col-lg-7'), css_class='justify-content-lg-around'), Row(Submit('submit', submit_text, css_class='btn btn-primary col-5 col-lg-6'), Reset('reset', _('Clean'), css_class='btn btn-secondary col-5 d-lg-none'), css_class='justify-content-around'))
def __init__(self, *args, **kwargs): super(ChamadosChangeForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.form_method = 'post' self.helper.add_input(Submit('submit', 'Enviar')) self.helper.add_input( Reset('reset', 'Limpar', css_class='btn-danger float-right'))
def __init__(self, user, *args, **kwargs): super(GlucoseFilterForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'filter_form' self.helper.form_method = 'post' self.helper.form_action = '.' self.fields['tags'] = forms.ChoiceField(choices=self.get_tags( Glucose.objects.filter(user=user).exclude( tags__name__isnull=True)), required=False) self.helper.layout = Layout( 'quick_date_select', Field('start_date', placeholder='From (mm/dd/yyyy)'), Field('end_date', placeholder='To (mm/dd/yyyy)'), 'category', Field('start_value', placeholder='From', step='any'), Field('end_value', placeholder='To', step='any'), 'notes', Field('tags'), FormActions( Submit('submit', 'Filter'), Reset('reset', 'Reset'), ), )
def __init__(self, *args, **kwargs): super(AventuraForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.form_method = 'POST' self.helper.layout = Layout( Row(Column( 'titulo', css_class='form-group col-md-8 col-md-offset-8 mx-auto'), css_class='form-row'), Row(Column( 'aventura', css_class='form-group col-md-8 col-md-offset-8 mx-auto'), css_class='form-row'), Row(Column( 'genero', css_class='form-group col-md-3 col-md-offset-3 mx-auto'), Column( 'numeroJogadores', css_class='form-group col-md-3 col-md-offset-3 mx-auto'), css_class='form-row'), Row(Column( 'npcs', css_class='form-group col-md-4 col-md-offset-4 mx-auto'), Column( 'itens', css_class='form-group col-md-4 col-md-offset-4 mx-auto'), css_class='form-row'), ) self.helper.add_input( Submit('submit', 'Criar', css_class='btn-success')) self.helper.add_input(Reset('reset', 'Limpar', css_class='btn-danger '))
def __init__(self, *args, **kwargs): # POP from kwargs action = kwargs.pop('action', None) super(BillBoardForm, self).__init__(*args, **kwargs) # Input label self.fields['subject'].label = _('Subject') self.fields['body'].label = _('Note ') # control Required self.fields['subject'].required = True self.fields['body'].required = True # init self.fields['body'].widget.attrs['rows'] = 3 # It builds a default layout with all its fields self.helper = FormHelper(self) self.helper.form_id = 'billboard-form-id' self.helper.form_method = 'post' self.helper.form_action = action self.helper.layout = Layout( Div(css_class='clearfix'), Div(css_class='divider-md'), Div( Div(Field('subject', placeholder=_('Subject')), css_class='form-group'), Div(Field('body', placeholder=_('Note')), css_class='form-group'), Div(Reset(_('Cancel'), _('Cancel'), css_class='btn btn-default btn-lg min-btn'), Submit(_('Save'), _('Save'), css_class='btn btn-primary btn-lg min-btn'), css_class='text-center divider-lg')))