diff --git a/rest_framework/static/rest_framework/js/default.js b/rest_framework/static/rest_framework/js/default.js index ecaccc0f0..fc386d6b8 100644 --- a/rest_framework/static/rest_framework/js/default.js +++ b/rest_framework/static/rest_framework/js/default.js @@ -3,3 +3,11 @@ prettyPrint(); $('.js-tooltip').tooltip({ delay: 1000 }); + +$('#patch-form').find('.field-switcher').on('change', function() { + var $this = $(this); + $('#patch-form').find('#'+$this.attr('data-field-id')) + .prop('disabled', !$this.prop('checked')); +}); + +$('#form-method-switcher a:first').tab('show'); diff --git a/rest_framework/templates/rest_framework/base.html b/rest_framework/templates/rest_framework/base.html index 8ab9c5857..0c0b3351b 100644 --- a/rest_framework/templates/rest_framework/base.html +++ b/rest_framework/templates/rest_framework/base.html @@ -147,56 +147,63 @@ {% endif %} - {% if put_form %} + {% if put_form or patch_form %}
-
-
- - {% csrf_token %} - {{ put_form.non_field_errors }} - {% for field in put_form %} -
- {{ field.label_tag|add_class:"control-label" }} -
- {{ field }} - {{ field.help_text }} - -
-
- {% endfor %} -
- -
- -
-
-
- {% endif %} - - {% if patch_form %} -
-
-
- - {% csrf_token %} - {{ patch_form.non_field_errors }} - {% for field in patch_form %} -
- {{ field.label_tag|add_class:"control-label" }} -
- {{ field }} - {{ field.help_text }} - + +
+ {% if put_form %} +
+ +
+ + {% csrf_token %} + {{ put_form.non_field_errors }} + {% for field in put_form %} +
+ {{ field.label_tag|add_class:"control-label" }} +
+ {{ field }} + {{ field.help_text }} + +
+ {% endfor %} +
+
- {% endfor %} -
- -
- -
- +
+ +
+ {% endif %} + {% if patch_form %} +
+
+
+ + {% csrf_token %} + {{ patch_form.non_field_errors }} + {% for field in patch_form %} +
+ {{ field.label_tag|add_class:"control-label" }} +
+ {{ field }}  + {{ field.help_text }} + +
+
+ {% endfor %} +
+ +
+
+
+
+ {% endif %} + {% endif %} {% endif %}