diff --git a/netbox/dcim/forms/common.py b/netbox/dcim/forms/common.py index 4341ec041..b42d5d815 100644 --- a/netbox/dcim/forms/common.py +++ b/netbox/dcim/forms/common.py @@ -10,6 +10,12 @@ __all__ = ( 'ModuleCommonForm' ) +COMPONENT_BULK_CREATE_HELP_TEXT = ( + "Alphanumeric ranges are supported for bulk creation. Mixed cases and types " + "within a single range are not supported (example: [ge,xe]-0/0/[0-9]). The string " + "{module} will be replaced with the position of the assigned module, if any." +) + class InterfaceCommonForm(forms.Form): mac_address = forms.CharField( diff --git a/netbox/dcim/forms/model_forms.py b/netbox/dcim/forms/model_forms.py index 908312a8a..5ca5690dc 100644 --- a/netbox/dcim/forms/model_forms.py +++ b/netbox/dcim/forms/model_forms.py @@ -19,7 +19,7 @@ from utilities.forms.rendering import FieldSet, InlineFields, TabbedGroups from utilities.forms.widgets import APISelect, ClearableFileInput, HTMXSelect, NumberWithOptions, SelectWithPK from virtualization.models import Cluster from wireless.models import WirelessLAN, WirelessLANGroup -from .common import InterfaceCommonForm, ModuleCommonForm +from .common import COMPONENT_BULK_CREATE_HELP_TEXT, InterfaceCommonForm, ModuleCommonForm __all__ = ( 'CableForm', @@ -909,6 +909,9 @@ class ModularComponentTemplateForm(ComponentTemplateForm): if self.instance.pk: self.fields['module_type'].disabled = True + # Components attached to a module need to present this standardized substitution help text. + self.fields['name'].help_text = _(COMPONENT_BULK_CREATE_HELP_TEXT) + class ConsolePortTemplateForm(ModularComponentTemplateForm): fieldsets = ( diff --git a/netbox/dcim/forms/object_create.py b/netbox/dcim/forms/object_create.py index fd8b88a8a..9222e5c90 100644 --- a/netbox/dcim/forms/object_create.py +++ b/netbox/dcim/forms/object_create.py @@ -7,6 +7,7 @@ from utilities.forms.fields import DynamicModelChoiceField, DynamicModelMultiple from utilities.forms.rendering import FieldSet from utilities.forms.widgets import APISelect from . import model_forms +from .common import COMPONENT_BULK_CREATE_HELP_TEXT __all__ = ( 'ComponentCreateForm', @@ -57,11 +58,7 @@ class ComponentCreateForm(forms.Form): # Components attached to a module need to present this standardized substitution help text. if 'module' in self.fields: - self.fields['name'].help_text = _( - "Alphanumeric ranges are supported for bulk creation. Mixed cases and types within a single range are " - "not supported (example: [ge,xe]-0/0/[0-9]). The string {module} will be " - "replaced with the position of the assigned module, if any." - ) + self.fields['name'].help_text = _(COMPONENT_BULK_CREATE_HELP_TEXT) def clean(self): super().clean()