2016-08-24 08:12:20 +01:00
source: Developing/Dynamic-Config.md
2018-10-27 23:04:34 +01:00
path: blob/master/doc/
2019-06-20 13:53:45 -05:00
2015-10-12 21:49:35 +00:00
# Adding new config options to WebUI
2019-06-20 13:53:45 -05:00
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.
2015-10-12 21:49:35 +00:00
#### 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
2019-06-20 13:53:45 -05:00
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:
2015-10-12 21:49:35 +00:00
2015-11-17 11:11:03 +00:00
[Commit example ](https://github.com/librenms/librenms/commit/c5998f9ee27acdac0c0f7d3092fc830c51ff684c )
2015-10-12 22:08:30 +00:00
2015-10-12 21:49:35 +00:00
```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">
2019-07-17 07:20:26 -05:00
' . csrf_field ();
2015-10-12 21:49:35 +00:00
2016-08-18 20:28:22 -05:00
echo generate_dynamic_config_panel ( 'Email transport' , $config_groups , $mail_conf , 'mail' );
2015-10-12 21:49:35 +00:00
echo '
</form>
</div>
' ;
```
And that should be it!