I am trying to create a web page that displays tabs at the top. Each tab relates to more than one model. I am using CrispyForms as follows:
class TestCrispyForm(forms.ModelForm):
helper = FormHelper()
helper.form_tag = False
helper.layout = Layout(
TabHolder(
Tab(
'Name',
'firstname',
'lastname'
),
Tab(
'Address',
'address',
'city',
'state'
),
Tab(
'Miscellaneous',
'sex',
'age',
'birthday',
'email'
),
)
)
class Meta:
model = PtData
class TestCrispyForm2(forms.ModelForm):
helper = FormHelper()
helper.form_tag = False
helper.layout = Layout(
TabHolder(
Tab(
'Tab 3',
InlineRadios('HypertensionHX')
),
Tab(
'Tab 4',
'DNADX'
),
)
)
class Meta:
model = PtHx
I would like to combine both forms and display the tabs across the top of the rendered page ... here is the html code:
<form action="" method="POST">{% csrf_token %}
{% crispy form %}
{% crispy form2 %}
<input type="submit" value="Submit">
</form>
This works, but displays the forms in order and cannot for the life of me (know enough here to be dangerous ;)) figure this one out. Anyone?
Thank you in advance for your help/assistance in this matter.
-Bob-
If you want put all tabs to one holder - simply create "TabHolder" markup manually (copy paste autogenereted one from browser) in your template and in your forms.py you can split your form to several helpers:
template: