diff --git a/tests/unit/forms.py b/tests/unit/forms.py new file mode 100644 index 00000000..1ee6caeb --- /dev/null +++ b/tests/unit/forms.py @@ -0,0 +1,6 @@ +from django import forms + + +class AllElementsForm(forms.Form): + text_input = forms.CharField(help_text="Sample text input") + another_input = forms.CharField(show_hidden_initial=True) diff --git a/tests/unit/templates/unit/form.html b/tests/unit/templates/unit/form.html new file mode 100644 index 00000000..8196f88a --- /dev/null +++ b/tests/unit/templates/unit/form.html @@ -0,0 +1,38 @@ +{% load viewflow %} + + + + + + + Form Sample Template + + + + +
+ + +
+ {% viewform 'unit/form_layout.html' %} + {% endviewform %} +
+ + + +
+ + {{ form.as_table }} +
+
+
+ + + + + + diff --git a/tests/unit/templates/unit/form_layout.html b/tests/unit/templates/unit/form_layout.html new file mode 100644 index 00000000..98b60653 --- /dev/null +++ b/tests/unit/templates/unit/form_layout.html @@ -0,0 +1,7 @@ +{% load viewflow %} + +{% for field in form.visible_fields %} + {% viewpart field field.html_name %} + {% viewfield field %} + {% endviewpart %} +{% endfor %} diff --git a/tests/unit/templates/unit/test_render_form.html b/tests/unit/templates/unit/test_render_form.html deleted file mode 100644 index b7d564cb..00000000 --- a/tests/unit/templates/unit/test_render_form.html +++ /dev/null @@ -1,10 +0,0 @@ -{% load viewflow %} -{% viewpart field 'username' %} -AAA -{% endviewpart %} - -{% for field in form.visible_fields %} - {% viewpart field field.name %} - {{ field.name }} - {% endviewpart %} -{% endfor %} diff --git a/tests/urls.py b/tests/urls.py index 95281dac..f62b5482 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -1,6 +1,8 @@ from django.conf.urls import patterns, include, url from django.contrib import admin from django.views.generic.base import TemplateView +from django.views.generic.edit import FormView +from unit.forms import AllElementsForm admin.autodiscover() @@ -11,5 +13,8 @@ url(r'^admin/', include(admin.site.urls)), url(r'^examples/shipment/', include('examples.shipment.urls')), url(r'^examples/helloworld/', include('examples.helloworld.urls')), + url(r'^examples/form/$', FormView.as_view( + form_class=AllElementsForm, + template_name='unit/form.html')), url(r'^', include('examples.website')), ) diff --git a/viewflow/templates/viewflow/form/widgets/text_input.html b/viewflow/templates/viewflow/form/widgets/text_input.html index 30171c4b..c7e0fea6 100644 --- a/viewflow/templates/viewflow/form/widgets/text_input.html +++ b/viewflow/templates/viewflow/form/widgets/text_input.html @@ -1,8 +1,10 @@ -{% include 'viewflow/form/field_errors.html' %} -