Hello,

I am using centreon 2.7.4 . This is related to a fifth plugin that I am developing for Centreon.

I am working on adding a page in the Admin section. One of the form objects would be a SELECT2 ui object, filling with data from a new table.

The usual flow for adding this, taking timeperiods as an example and copied from the hosts page:

Code:
$host_id=100;
$attrTimeperiods = array(
        'datasourceOrigin' => 'ajax',
        'availableDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_timeperiod&action=list',
        'multiple' => false,
        'linkedObject' => 'centreonTimeperiod'
);
$attrTimeperiod1 = array_merge(
    $attrTimeperiods,
    array('defaultDatasetRoute' => './include/common/webServices/rest/internal.php?object=centreon_configuration_timeperiod&action=defaultValues&target=host&field=timeperiod_tp_id&id=' . $host_id)
);
$form->addElement('select2', 'hg_hosts', _("Check Period"), array(), $attrTimeperiod1);
However, I am using my own table and records, in my own module. I have altered the above code to reflect my own module, and I have created PHP file with class in {MODULE-NAME}/webServices/rest/ , and debugging tests show this is working and called fine. When setting $attrTimeperiods["multiple"] to true, this works fine (both initial values, selection values, and selected values are all populating fine).

However, only a single value is needed. When setting $attrTimeperiods["multiple"] to false (to emulate a basic dropdown object), initial values no longer work fine (selection values and selecting values do work fine): a 0 is displayed when $attrTimeperiods['linkedObject'] = '{MY_OWN_CLASS}' is set, or timezone values are used when kept at $attrTimeperiods['linkedObject'] = 'centreonTimeperiod'.

Looking at this in more depth, it seems that CentreonWebService::router() in include/common/webServices/rest/internal.php is correctly called when loading initial values for multiple SELECT2 values, but it seems that for single SELECT2 values, Smarty is calling a different route and using the $attrTimeperiods['linkedObject'] value in some unknown obscure php methodology route. It furthermore seems that CentreonWebService::router() is correctly loading all centreon AND module configuration objects (from which my module class is then found), but the obscure php methodology as described, is only using centreon classes located in /www/class/*.class.php (which is out of reach for my module).

This is p*ssing me off. I want to re-use existing objects, and be able to use SELECT2 for single values.

Is someone familiar with this? Is there a fix? Is there a known work-around? Should this be a bug-report? Where are the bug-reports?

Florian Mertens