Browse Source

Fixes #12190: Fix form layout for plugin textarea fields

jeremystretch 2 years ago
parent
commit
63a0ec7a79

+ 1 - 0
docs/release-notes/version-3.4.md

@@ -14,6 +14,7 @@
 * [#12084](https://github.com/netbox-community/netbox/issues/12084) - Fix exception when attempting to create a saved filter for applied filters
 * [#12087](https://github.com/netbox-community/netbox/issues/12087) - Fix bulk editing of many-to-many relationships
 * [#12117](https://github.com/netbox-community/netbox/issues/12117) - Hide clone button for objects with no clonable attributes
+* [#12190](https://github.com/netbox-community/netbox/issues/12190) - Fix form layout for plugin textarea fields
 
 ---
 

+ 1 - 1
netbox/templates/dcim/cable_edit.html

@@ -98,7 +98,7 @@
             <div class="card">
               <h5 class="card-header text-center">Comments</h5>
               <div class="card-body">
-              {% render_field form.comments %}
+                {% render_field form.comments %}
               </div>
             </div>
           {% if form.custom_fields %}

+ 0 - 1
netbox/templates/dcim/device_edit.html

@@ -111,7 +111,6 @@
     </div>
 
     <div class="field-group mb-5">
-      <h5 class="text-center">Comments</h5>
       {% render_field form.comments %}
     </div>
 

+ 0 - 1
netbox/templates/dcim/rack_edit.html

@@ -85,7 +85,6 @@
     {% endif %}
 
     <div class="field-group my-5">
-      <h5 class="text-center">Comments</h5>
       {% render_field form.comments %}
     </div>
 {% endblock %}

+ 0 - 1
netbox/templates/dcim/virtualchassis_edit.html

@@ -27,7 +27,6 @@
         </div>
 
         <div class="field-group my-5">
-          <h5 class="text-center">Comments</h5>
           {% render_field vc_form.comments %}
         </div>
 

+ 0 - 1
netbox/templates/generic/object_edit.html

@@ -85,7 +85,6 @@ Context:
 
             {% if form.comments %}
               <div class="field-group mb-5">
-                <h5 class="text-center">Comments</h5>
                 {% render_field form.comments %}
               </div>
             {% endif %}

+ 0 - 3
netbox/templates/ipam/fhrpgroup_edit.html

@@ -33,9 +33,6 @@
   {% endif %}
 
   <div class="field-group mb-5">
-    <div class="row mb-2">
-      <h5 class="offset-sm-3">Comments</h5>
-    </div>
     {% render_field form.comments %}
   </div>
 

+ 0 - 3
netbox/templates/ipam/ipaddress_edit.html

@@ -139,9 +139,6 @@
     </div>
 
     <div class="field-group my-5">
-      <div class="row mb-2">
-        <h5 class="text-center">Comments</h5>
-      </div>
       {% render_field form.comments %}
     </div>
 

+ 0 - 3
netbox/templates/ipam/service_create.html

@@ -66,9 +66,6 @@
   </div>
 
   <div class="field-group my-5">
-    <div class="row mb-2">
-      <h5 class="text-center">Comments</h5>
-    </div>
     {% render_field form.comments %}
   </div>
 

+ 0 - 3
netbox/templates/ipam/service_edit.html

@@ -53,9 +53,6 @@
   </div>
 
   <div class="field-group my-5">
-    <div class="row mb-2">
-      <h5 class="text-center">Comments</h5>
-    </div>
     {% render_field form.comments %}
   </div>
 

+ 0 - 3
netbox/templates/ipam/vlan_edit.html

@@ -56,9 +56,6 @@
   </div>
 
   <div class="field-group my-5">
-    <div class="row mb-2">
-      <h5 class="text-center">Comments</h5>
-    </div>
     {% render_field form.comments %}
   </div>
 

+ 0 - 39
netbox/templates/wireless/wirelesslink_edit.html

@@ -1,39 +0,0 @@
-{% extends 'generic/object_edit.html' %}
-{% load form_helpers %}
-
-{% block form %}
-  <div class="row">
-    <div class="col">
-      <div class="field-group">
-        <div class="row mb-2">
-          <h5 class="offset-sm-3">Side A</h5>
-        </div>
-        {% render_field form.device_a %}
-        {% render_field form.interface_a %}
-      </div>
-    </div>
-    <div class="col">
-      <div class="field-group">
-        <div class="row mb-2">
-          <h5 class="offset-sm-3">Side B</h5>
-        </div>
-        {% render_field form.device_b %}
-        {% render_field form.interface_b %}
-      </div>
-    </div>
-  </div>
-  <div class="field-group my-5">
-    <div class="row mb-2">
-      <h5 class="offset-sm-3">Comments</h5>
-    </div>
-    {% render_field form.comments %}
-  </div>
-  {% if form.custom_fields %}
-    <div class="field-group my-5">
-      <div class="row mb-2">
-        <h5 class="offset-sm-3">Custom Fields</h5>
-      </div>
-      {% render_custom_fields form %}
-    </div>
-  {% endif %}
-{% endblock %}

+ 2 - 2
netbox/utilities/forms/fields/fields.py

@@ -34,8 +34,8 @@ class CommentField(forms.CharField):
         Markdown</a> syntax is supported
     """
 
-    def __init__(self, *, label='', help_text=help_text, required=False, **kwargs):
-        super().__init__(label=label, help_text=help_text, required=required, **kwargs)
+    def __init__(self, *, help_text=help_text, required=False, **kwargs):
+        super().__init__(help_text=help_text, required=required, **kwargs)
 
 
 class SlugField(forms.SlugField):

+ 2 - 5
netbox/utilities/templates/form_helpers/render_field.html

@@ -3,11 +3,8 @@
 
 <div class="row mb-3{% if field.errors %} has-errors{% endif %}">
 
-  {# Render the field label, except for: #}
-  {#   1. Checkboxes (label appears to the right of the field #}
-  {#   2. Textareas with no label set (will expand across entire row) #}
-  {% if field|widget_type == 'checkboxinput' or field|widget_type == 'textarea' or field|widget_type == 'markdownwidget' and not label %}
-  {% else %}
+  {# Render the field label, except for checkboxes #}
+  {% if field|widget_type != 'checkboxinput' %}
     <label for="{{ field.id_for_label }}" class="col-sm-3 col-form-label text-lg-end{% if field.field.required %} required{% endif %}">
       {{ label }}
     </label>