mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Fixes: #17459 - Ensure help text on component create forms shows both bulk edit and substitution token instructions (#17931)
* Move {module} substitution help text to main ComponentCreateForm.__init__ so it applies to all component types, and fix formatting * Simplify help text replacement string for component forms with 'module' field * Reuse help text string in both ComponentCreateForm and ModularComponentTemplateForm * Remove help text override from regular (direct) object creation of device components * Re-add space * Tweak help text --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
4f7bfc836c
commit
6fb476081e
@ -909,6 +909,13 @@ class ModularComponentTemplateForm(ComponentTemplateForm):
|
|||||||
if self.instance.pk:
|
if self.instance.pk:
|
||||||
self.fields['module_type'].disabled = True
|
self.fields['module_type'].disabled = True
|
||||||
|
|
||||||
|
# Components attached to a module need to present this standardized substitution help text.
|
||||||
|
self.fields['name'].help_text = _(
|
||||||
|
"Alphanumeric ranges are supported for bulk creation. Mixed cases and types within a single range are not "
|
||||||
|
"supported (example: <code>[ge,xe]-0/0/[0-9]</code>). The token <code>{module}</code>, if present, will be "
|
||||||
|
"automatically replaced with the position value when creating a new module."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ConsolePortTemplateForm(ModularComponentTemplateForm):
|
class ConsolePortTemplateForm(ModularComponentTemplateForm):
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
|
@ -243,14 +243,6 @@ class InterfaceCreateForm(ComponentCreateForm, model_forms.InterfaceForm):
|
|||||||
class Meta(model_forms.InterfaceForm.Meta):
|
class Meta(model_forms.InterfaceForm.Meta):
|
||||||
exclude = ('name', 'label')
|
exclude = ('name', 'label')
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
if 'module' in self.fields:
|
|
||||||
self.fields['name'].help_text += _(
|
|
||||||
"The string <code>{module}</code> will be replaced with the position of the assigned module, if any."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm):
|
class FrontPortCreateForm(ComponentCreateForm, model_forms.FrontPortForm):
|
||||||
device = DynamicModelChoiceField(
|
device = DynamicModelChoiceField(
|
||||||
|
Loading…
Reference in New Issue
Block a user