I'm a beginner in Mantis, but I have to do some customizations for my office.
Ok, the problem is that we need some dynamic custom fields which can read from the database
from selfmade tables like "mantis_custom_field_table_device". I have already created the table
with the fields ID, Type and Device.
I have found in the manuel the point http://docs.mantisbt.org/master/en/admi ... DS.DYNAMIC
and based on that I created a custom function in custom_function_api.php. It is already able to read the data
from the database (tested by an echo output) but it cannot write it to an array and I don't what can be the problem.
The source code:
Code: Select all
<?php
function custom_function_override_enum_devices() {
global $g_db;
$rows = array();
$query = "SELECT *
FROM mantis_custom_field_table_device";
$result = db_query_bound($query);
echo "Query Ergebnis: ". $result ."<br />";
if( !$result ) {
db_error( $query );
echo 'SQL query syntax Fehler';
trigger_error( ERROR_DB_QUERY_FAILED, ERROR );
return false;
} else {
$count = $result->RecordCount();
echo "Anz.: ". $count ."<br />";
for ($i=0; $i<$count; $i++) {
$row = db_fetch_array( $result);
echo "Device ".$i.": ". $row['Device'] ."<br />";
$rows[$i] = $row['Device'];
$rows[$i+2] = "test";
}
}
$t_possible_values = implode( '|', $rows );
return $t_possible_values;
}
?>
The output of the test echos is:
Query Ergebnis: DeviceID,Type,Device 1,aaaa,testA 2,bbbbb,testB
Anz.: 2
Device 0:
Device 1:
and a dropdown list with blank|test|blank|test
The Mantis version I am testing this is 1.2.5
It would be nice if somebody could help me, because I don't find where the problem is?
Many thanks
Michael