Files
librenms-librenms/doc/Developing/Dynamic-Config.md
VVelox 6575042f5f go through making lots of the docs more lint happy (#10342)
* clean up all but header incrementing in Creating-Transport.md

* make Device-Dependencies.md mdl happy

* make Entities.md as mdl happy as possible... one long table line left

* make mdl as happy as possible for index.md

* clean up Introduction.md as much as possible

* minor formatting cleanup... move each icon onto its own row

* make ack and notes the same style

* clean Macros.md up

* clean Rules.md up as much as possible

* tweak one line a bit to get it to format a bit nicer

* a bit more format tweaking, making sure it does not sure with >

* clean up as much as possible for Templates.md

* make Testing.md as mdl happy as possibly

* clean Transports.md up as much as possible

* clean as many issues as possible for Alerts.md

* clean up as much of ARP.md as possible

* clean up as much as possible for Bills.md

* make DeviceGroups.md as mdl happy as possible

* cleanup Devices.md

* make as mdl happy as possible Inventory.md and index.md

* mdl cleanup for Logs.md and PortGroups.md

* make Ports.md and Routing.md as happy as possible

* clean up Services.md, Switching.md, and Systems.md as much as possible

* more markup cleanup

* lots more md cleanup udner Devloping/

* reapply bits from #10343 that accidentally got removed when merging
2019-06-20 13:53:44 -05:00

57 lines
1.6 KiB
Markdown

source: Developing/Dynamic-Config.md
path: blob/master/doc/
# Adding new config options to WebUI
Adding support for users to update a new config option via the WebUI
is now a lot easier for general options. This document shows you how
to add a new config option and even section to the WebUI.
#### Update DB
Firstly you will need to add the config option to the database. Here's an example:
```sql
insert into config (config_name,config_value,config_default,config_descr,config_group,config_group_order,config_sub_group,config_sub_group_order,config_hidden,config_disabled) values ('alert.tolerance_window','','','Tolerance window in seconds','alerting',0,'general',0,'0','0');
```
This will determine the default config option for `$config['alert']['tolerance_window']`.
#### Update WebUI
If the sub-section you want to add the new config option already
exists then update the relevant file within `html/pages/settings/`
otherwise you will need to create the new sub-section page. Here's an
example of this:
[Commit example](https://github.com/librenms/librenms/commit/c5998f9ee27acdac0c0f7d3092fc830c51ff684c)
```php
<?php
$no_refresh = true;
$config_groups = get_config_by_group('alerting');
$mail_conf = array(
array('name' => 'alert.tolerance_window',
'descr' => 'Tolerance window for cron',
'type' => 'text',
),
);
echo '
<div class="panel-group" id="accordion">
<form class="form-horizontal" role="form" action="" method="post">
';
echo generate_dynamic_config_panel('Email transport',$config_groups,$mail_conf,'mail');
echo '
</form>
</div>
';
```
And that should be it!