From fc7235e636d9aa592b1f470d7a9add74e3ea6d1e Mon Sep 17 00:00:00 2001 From: David Smith Date: Sat, 11 Jul 2020 20:53:12 +0100 Subject: [PATCH] Horizontal forms * checkbox are now fully custom by default in Bootstrap5 - removed previous tweaks. * control-label --> col-form-label * errors now need `invalid-feedback` on the text and `is-invalid` on the input * new `form-text` class for help text * New html layout and css classes for radio/multiple checkbox. Added work around for errors and inline (see comments in code). --- .../rest_framework/css/bootstrap-tweaks.css | 14 ----- .../rest_framework/horizontal/checkbox.html | 12 ++-- .../horizontal/checkbox_multiple.html | 45 +++++++-------- .../rest_framework/horizontal/dict_field.html | 6 +- .../rest_framework/horizontal/fieldset.html | 4 +- .../rest_framework/horizontal/input.html | 10 ++-- .../rest_framework/horizontal/list_field.html | 6 +- .../horizontal/list_fieldset.html | 4 +- .../rest_framework/horizontal/radio.html | 57 +++++++------------ .../rest_framework/horizontal/select.html | 10 ++-- .../horizontal/select_multiple.html | 10 ++-- .../rest_framework/horizontal/textarea.html | 10 ++-- 12 files changed, 77 insertions(+), 111 deletions(-) diff --git a/rest_framework/static/rest_framework/css/bootstrap-tweaks.css b/rest_framework/static/rest_framework/css/bootstrap-tweaks.css index e626a7735..523092e98 100644 --- a/rest_framework/static/rest_framework/css/bootstrap-tweaks.css +++ b/rest_framework/static/rest_framework/css/bootstrap-tweaks.css @@ -198,20 +198,6 @@ body a:hover { clear:both; } -.horizontal-checkbox label { - padding-top: 0; -} - -.horizontal-checkbox label { - padding-top: 0 !important; -} - -.horizontal-checkbox input { - float: left; - width: 20px; - margin-top: 3px; -} - .modal-footer form { margin-left: 5px; margin-right: 5px; diff --git a/rest_framework/templates/rest_framework/horizontal/checkbox.html b/rest_framework/templates/rest_framework/horizontal/checkbox.html index 0d74d46ab..65a98a1c2 100644 --- a/rest_framework/templates/rest_framework/horizontal/checkbox.html +++ b/rest_framework/templates/rest_framework/horizontal/checkbox.html @@ -1,21 +1,23 @@ -
+
{% if field.label %} -
diff --git a/rest_framework/templates/rest_framework/horizontal/checkbox_multiple.html b/rest_framework/templates/rest_framework/horizontal/checkbox_multiple.html index 2c55c77ee..7cb7a8847 100644 --- a/rest_framework/templates/rest_framework/horizontal/checkbox_multiple.html +++ b/rest_framework/templates/rest_framework/horizontal/checkbox_multiple.html @@ -1,39 +1,32 @@ {% load rest_framework %} -
+
{% if field.label %} -
diff --git a/rest_framework/templates/rest_framework/horizontal/dict_field.html b/rest_framework/templates/rest_framework/horizontal/dict_field.html index bc5203b05..a13331b3b 100644 --- a/rest_framework/templates/rest_framework/horizontal/dict_field.html +++ b/rest_framework/templates/rest_framework/horizontal/dict_field.html @@ -1,11 +1,11 @@ -
+
{% if field.label %} -
diff --git a/rest_framework/templates/rest_framework/horizontal/fieldset.html b/rest_framework/templates/rest_framework/horizontal/fieldset.html index 3b0b7af41..fe5aae41f 100644 --- a/rest_framework/templates/rest_framework/horizontal/fieldset.html +++ b/rest_framework/templates/rest_framework/horizontal/fieldset.html @@ -1,8 +1,8 @@ {% load rest_framework %}
{% if field.label %} -
- +
+ {{ field.label }}
diff --git a/rest_framework/templates/rest_framework/horizontal/input.html b/rest_framework/templates/rest_framework/horizontal/input.html index dbc44d819..8b5e63e70 100644 --- a/rest_framework/templates/rest_framework/horizontal/input.html +++ b/rest_framework/templates/rest_framework/horizontal/input.html @@ -1,21 +1,21 @@ -
+
{% if field.label %} -
diff --git a/rest_framework/templates/rest_framework/horizontal/list_field.html b/rest_framework/templates/rest_framework/horizontal/list_field.html index e1761c1d9..316ea6748 100644 --- a/rest_framework/templates/rest_framework/horizontal/list_field.html +++ b/rest_framework/templates/rest_framework/horizontal/list_field.html @@ -1,11 +1,11 @@ -
+
{% if field.label %} -
diff --git a/rest_framework/templates/rest_framework/horizontal/list_fieldset.html b/rest_framework/templates/rest_framework/horizontal/list_fieldset.html index 89f6a5b87..2c4a380e3 100644 --- a/rest_framework/templates/rest_framework/horizontal/list_fieldset.html +++ b/rest_framework/templates/rest_framework/horizontal/list_fieldset.html @@ -2,8 +2,8 @@
{% if field.label %} -
- +
+ {{ field.label }}
diff --git a/rest_framework/templates/rest_framework/horizontal/radio.html b/rest_framework/templates/rest_framework/horizontal/radio.html index 56bfda0c1..c3004dd70 100644 --- a/rest_framework/templates/rest_framework/horizontal/radio.html +++ b/rest_framework/templates/rest_framework/horizontal/radio.html @@ -3,55 +3,40 @@ {% trans "None" as none_choice %} -
+
{% if field.label %} -
+
\ No newline at end of file diff --git a/rest_framework/templates/rest_framework/horizontal/select.html b/rest_framework/templates/rest_framework/horizontal/select.html index d1b5e137e..31cd153a7 100644 --- a/rest_framework/templates/rest_framework/horizontal/select.html +++ b/rest_framework/templates/rest_framework/horizontal/select.html @@ -1,14 +1,14 @@ {% load rest_framework %} -
+
{% if field.label %} -
diff --git a/rest_framework/templates/rest_framework/horizontal/select_multiple.html b/rest_framework/templates/rest_framework/horizontal/select_multiple.html index e48a4242f..86d1af494 100644 --- a/rest_framework/templates/rest_framework/horizontal/select_multiple.html +++ b/rest_framework/templates/rest_framework/horizontal/select_multiple.html @@ -3,15 +3,15 @@ {% trans "No items to select." as no_items %} -
+
{% if field.label %} -
diff --git a/rest_framework/templates/rest_framework/horizontal/textarea.html b/rest_framework/templates/rest_framework/horizontal/textarea.html index 8d5da811f..f8febe800 100644 --- a/rest_framework/templates/rest_framework/horizontal/textarea.html +++ b/rest_framework/templates/rest_framework/horizontal/textarea.html @@ -1,21 +1,21 @@ -
+
{% if field.label %} -