Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fields_host_edit method on config_form, add more 'method' to be able to have sql_query and kind of text_box #5349

Open
arno-st opened this issue Jun 6, 2023 · 1 comment
Labels
enhancement General tag for an enhancement
Milestone

Comments

@arno-st
Copy link
Contributor

arno-st commented Jun 6, 2023

Hello guys,
On a extension of the config_form of all device, I have a drop_sql method (that part works).
This field in the DB is populated automatically when my discovery process find a equipment. It's almost like automation, but using only CDP and SNMP call to gather all the info of the device, and I get the serial number and the device type.

But sometime, old switch, the OID dosen't exist or can't be read. So I'd like to offer the possibility to the user to fill the fields_host_edit with his own value; when he edit a device.

Is their a possibility to do that ?
here my fields_host_edit add on (partial code):

$fields_host_edit3['extenddb_header'] = array( 'friendly_name' => __('Extend DB'), 'method' => 'spacer', 'collapsible' => 'true' ); $fields_host_edit3['serial_no'] = array( 'method' => 'drop_sql', 'friendly_name' => 'Serial No', 'description' => 'Enter the serial number.', 'max_length' => 50, 'value' => '|arg1:serial_no|', 'sql' => 'SELECT id, serial_no AS name FROM plugin_extenddb_host_serial_no WHERE host_id="|arg1:id|"', 'default' => '', ); $fields_host_edit3['model'] = array( 'friendly_name' => 'Model', 'description' => 'This is the model of equipement.', 'method' => 'drop_sql', 'max_length' => 50, 'value' => '|arg1:model|', 'sql' => 'SELECT id, model AS name FROM plugin_extenddb_host_model WHERE host_id="|arg1:id|"', 'default' => '', );

Frankly I have No idea how to do that.
I was looking to implement a drop_callback But in this case it's missing a api_plugin_hook who can let me do that for the host form.
I also think of the possibility that when the field is empty (set to none maybe) the drop down is a list taken from another table.
In my case have a table with all model of device I support.
I also try to have a a field of the type text_box with the value taken from this query
'value' => db_fetch_cell('SELECT id, serial_no AS name FROM plugin_extenddb_host_serial_no WHERE host_id='.'|arg1:id|'),
But I can't, I don'0t know how to use the |arg1:id| in y query.

I hope I give enough information for it.

@arno-st arno-st added the enhancement General tag for an enhancement label Jun 6, 2023
@netniV
Copy link
Member

netniV commented Jun 6, 2023

It sounds like you want a combo instead of drop. That would allow dynamic values.

@netniV netniV added this to the v1.3.0 milestone Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement General tag for an enhancement
Projects
None yet
Development

No branches or pull requests

2 participants