Quellcode durchsuchen

Fixes #9687: Don't restrict custom text field lengths when entering via UI form

jeremystretch vor 3 Jahren
Ursprung
Commit
5a4467a4a8

+ 1 - 1
docs/models/extras/customfield.md

@@ -10,7 +10,7 @@ Within the database, custom fields are stored as JSON data directly alongside ea
 
 Custom fields may be created by navigating to Customization > Custom Fields. NetBox supports six types of custom field:
 
-* Text: Free-form text (up to 255 characters)
+* Text: Free-form text (intended for single-line use)
 * Long text: Free-form of any length; supports Markdown rendering
 * Integer: A whole number (positive or negative)
 * Boolean: True or false

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

@@ -18,6 +18,7 @@
 * [#9632](https://github.com/netbox-community/netbox/issues/9632) - Automatically focus on search box when expanding dropdowns
 * [#9657](https://github.com/netbox-community/netbox/issues/9657) - Fix filtering for custom fields and webhooks in the UI
 * [#9682](https://github.com/netbox-community/netbox/issues/9682) - Fix bulk assignment of ASNs to sites
+* [#9687](https://github.com/netbox-community/netbox/issues/9687) - Don't restrict custom text field lengths when entering via UI form
 * [#9704](https://github.com/netbox-community/netbox/issues/9704) - Include `last_updated` field on JournalEntry REST API serializer
 
 ---

+ 2 - 7
netbox/extras/models/customfields.py

@@ -365,13 +365,8 @@ class CustomField(ExportTemplatesMixin, WebhooksMixin, ChangeLoggedModel):
 
         # Text
         else:
-            if self.type == CustomFieldTypeChoices.TYPE_LONGTEXT:
-                max_length = None
-                widget = forms.Textarea
-            else:
-                max_length = 255
-                widget = None
-            field = forms.CharField(max_length=max_length, required=required, initial=initial, widget=widget)
+            widget = forms.Textarea if self.type == CustomFieldTypeChoices.TYPE_LONGTEXT else None
+            field = forms.CharField(required=required, initial=initial, widget=widget)
             if self.validation_regex:
                 field.validators = [
                     RegexValidator(