Solved

Problem in Widget Preferences (hostMulti)

  • 9 December 2021
  • 2 replies
  • 75 views

Userlevel 1
Badge +4

Hello,
I'm having a problem developing my widget. When I configure my configs.xml file, I add an input like this:

<preference label="List Host Name" name="list_host" defaultValue="" type="hostMulti" header="Test"/>

When i fill it in like this and click on apply, host id are sent. But when I go back to widget preferences,  hosts I entered have disappeared and I get this kind of error :

You should know that when I only put one host in the input, no error is displayed

 

the input of the hosts does not work, but the input of the hostgroups (bellow) works very well.

<preference label="List Hostgroup Name" name="list_hostgroup" defaultValue="" type="hostGroupMulti" header="Test"/>

Do you have any idea where the problem comes from?

icon

Best answer by Laurent 13 December 2021, 12:05

View original

2 replies

Userlevel 6
Badge +18

Hi @Wisonic, I suppose their is a bug.

 

Can you create an issue on github ?

 

Can you try to change lines from 2484 to 2492 from /usr/share/centreon/www/class/centreonHost.class.php:

        if (!empty($values)) {
foreach ($values as $k => $v) {
$listValues .= ':host' . $v . ',';
$queryValues['host' . $v] = (int)$v;
}
$listValues = rtrim($listValues, ',');
} else {
$listValues .= "''";
}

To have:

        if (!empty($values)) {
foreach ($values as $k => $v) {
$multiValues = explode(',', $v);
foreach ($multiValues as $item) {
$listValues .= ':host' . $item . ',';
$queryValues['host' . $item] = (int)$item;
}
}
$listValues = rtrim($listValues, ',');
} else {
$listValues .= "''";
}

Regards

Userlevel 6
Badge +18

Github issue https://github.com/centreon/centreon/issues/10486

Reply