fields_host_edit method on config_form, add more 'method' to be able to have sql_query and kind of text_box #5349
Labels
enhancement
General tag for an enhancement
Milestone
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.
The text was updated successfully, but these errors were encountered: