netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Allow injection of form fields by plugins into standard models (and allow corresponding plugins to parse data on save)

Open DanSheps opened this issue 1 year ago • 3 comments

NetBox version

v3.7.0

Feature type

New functionality

Proposed functionality

Add a method to:

  • Allow plugins to inject form fields into a "core model" form (example: Interface)
    • Perhaps allow this to be done in a dynamic manner, such as only showing fields when certain properties are already selected, however this is not "core" to the proposal
  • Process the form field data and save via a "sub-form" save method (or whatever method is appropriate)

Use case

This would allow for extending of "core" models by plugins while not actually modifying the core model

As an example, lets say you want to the Interface model to collect more data regarding the layer 2 information (example, port security, spanning tree, etc). You would define the form and model in your plugin and tell it which form (or model) to hook into, it would then display the extra field in the corresponding model create/edit form. When saved, the form would validate both the parent form and the "sub-form" before saving.

Database changes

None required

External dependencies

None

DanSheps avatar Jan 08 '24 14:01 DanSheps

Seems duplicate of #11961

abhi1693 avatar Jan 08 '24 15:01 abhi1693

It does appear to be a duplicate. However that one was more or less also replalcing forms and manipulating data in the core model. This would be more akin to custom fields.

This however was brought up in a maintainers meeting a few months back by me which is why I am bringing it here (just a little lax on getting stuff from my brain into github)

DanSheps avatar Jan 09 '24 18:01 DanSheps

It may be a duplicate (I'd say so, it's pretty much the core of what I wanted to suggest with #11961), but things have changed since then as NetBox 3.7.0 saw the introduction of plugin-injected fields in standard models, so adding plugin-injected form fields is the logical next step.

I highly appreciate this new approach, as the functionality could make my life much easier in some places and also greatly improve user experience - Custom Fields can be a bit clumsy at times.

peteeckel avatar Feb 06 '24 08:02 peteeckel

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

github-actions[bot] avatar May 15 '24 12:05 github-actions[bot]