Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Accordion examples #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions bootstrap4/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field, Column
from crispy_forms.bootstrap import AppendedText, PrependedText, PrependedAppendedText, FormActions, InlineCheckboxes, \
InlineRadios
InlineRadios, Accordion, AccordionGroup
from django.utils import timezone

from bootstrap4 import models
Expand All @@ -20,6 +20,11 @@ class MessageForm(forms.Form):
text_input_b = forms.CharField()
text_input_c = forms.CharField()

text_input_accordion1 = forms.CharField()
text_input_accordion2 = forms.CharField()
text_input_accordion3 = forms.CharField()
text_input_accordion4 = forms.CharField()

textarea = forms.CharField(
widget=forms.Textarea(),
help_text="help on a textarea",
Expand Down Expand Up @@ -179,6 +184,21 @@ class MessageForm(forms.Form):
Column('text_input_c'),
),
'datetime_field',
HTML('<strong>First accordion:</strong>'),
Accordion(
AccordionGroup(
'Accordion Group 1', 'text_input_accordion1'),
AccordionGroup(
'Accordion Group 2', 'text_input_accordion2')
),
HTML('<strong>Second accordion:</strong>'),
Accordion(
AccordionGroup(
'Accordion Group 1', 'text_input_accordion3'),
AccordionGroup(
'Accordion Group 2', 'text_input_accordion4')
),

FormActions(
Submit('save_changes', 'Save changes', css_class="btn-primary"),
Submit('cancel', 'Cancel'),
Expand All @@ -192,6 +212,11 @@ class HorizontalMessageForm(forms.Form):
text_input_b = forms.CharField()
text_input_c = forms.CharField()

text_input_accordion1 = forms.CharField()
text_input_accordion2 = forms.CharField()
text_input_accordion3 = forms.CharField()
text_input_accordion4 = forms.CharField()

textarea = forms.CharField(
widget=forms.Textarea(),
)
Expand Down Expand Up @@ -304,6 +329,20 @@ class HorizontalMessageForm(forms.Form):
Field('boolean_field'),
Field('file_field'),
Field('file_field_raw'),
HTML('<strong>First accordion:</strong>'),
Accordion(
AccordionGroup(
'Accordion Group 1', 'text_input_accordion1'),
AccordionGroup(
'Accordion Group 2', 'text_input_accordion2')
),
HTML('<strong>Second accordion:</strong>'),
Accordion(
AccordionGroup(
'Accordion Group 1', 'text_input_accordion3'),
AccordionGroup(
'Accordion Group 2', 'text_input_accordion4')
),
FormActions(
Submit('save_changes', 'Save changes', css_class="btn-primary"),
Submit('cancel', 'Cancel'),
Expand All @@ -328,4 +367,4 @@ class Meta:
helper = FormHelper()
helper.label_class = 'col-4'
helper.field_class = 'col-8'
helper.form_class = 'form-horizontal'
helper.form_class = 'form-horizontal'