Hide hidden fields

This commit is contained in:
Andrea De Marco 2012-03-08 11:18:14 +01:00
parent 55317b0372
commit 7ad414cd60
2 changed files with 4 additions and 3 deletions

View File

@ -86,7 +86,7 @@
<h2>POST {{ name }}</h2> <h2>POST {{ name }}</h2>
{% csrf_token %} {% csrf_token %}
{{ post_form.non_field_errors }} {{ post_form.non_field_errors }}
{% for field in post_form %} {% for field in post_form.visible_fields %}
<div class='form-row'> <div class='form-row'>
{{ field.label_tag }} {{ field.label_tag }}
{{ field }} {{ field }}
@ -108,7 +108,7 @@
<input type="hidden" name="{{ METHOD_PARAM }}" value="PUT" /> <input type="hidden" name="{{ METHOD_PARAM }}" value="PUT" />
{% csrf_token %} {% csrf_token %}
{{ put_form.non_field_errors }} {{ put_form.non_field_errors }}
{% for field in put_form %} {% for field in put_form.visible_fields %}
<div class='form-row'> <div class='form-row'>
{{ field.label_tag }} {{ field.label_tag }}
{{ field }} {{ field }}

View File

@ -253,7 +253,8 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
if form is not None: if form is not None:
field_name_types = {} field_name_types = {}
for name, field in form.fields.iteritems(): for name, field in form.fields.iteritems():
field_name_types[name] = field.__class__.__name__ if not field.widget.is_hidden:
field_name_types[name] = field.__class__.__name__
response_obj['fields'] = field_name_types response_obj['fields'] = field_name_types
# Note 'ErrorResponse' is misleading, it's just any response # Note 'ErrorResponse' is misleading, it's just any response
# that should be rendered and returned immediately, without any # that should be rendered and returned immediately, without any