You are not logged in.
Hi!
I have followed every step in the Generic Object plugin documentation to add a custom field. I have created the necessary file at the file path glpi\files\_plugins\genericobject\fields\server.constant.php
Within the file, I added the required code statements as follows.
<?php
global $GO_FIELDS, $LANG;
$GO_FIELDS['plugin_genericobject_servertypes_id']['name'] = $LANG['genericobject']['PluginGenericobjectServer'][1];
$GO_FIELDS['plugin_genericobject_servertypes_id']['field'] = 'servertype';
$GO_FIELDS['plugin_genericobject_servertypes_id']['input_type'] = 'dropdown';
?>
I have also defined the necessary field label at the bottom of the file located at this file path: glpi\files\_plugins\genericobject\locales\server\server.en_US.php
$LANG['genericobject']['PluginGenericobjectServer'][1]="Server Name";
However, upon entering the 'Fields' section in the 'Objects Management' menu, several errors were displayed as follows.
Warning: Undefined array key "genericobject" in C:\xampp\htdocs\glpi\files\_plugins\genericobject\fields\server.constant.php on line 4
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\glpi\files\_plugins\genericobject\fields\server.constant.php on line 4
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\glpi\files\_plugins\genericobject\fields\server.constant.php on line 4
Warning: Undefined array key "genericobject" in C:\xampp\htdocs\glpi\files\_plugins\genericobject\fields\server.constant.php on line 4
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\glpi\files\_plugins\genericobject\fields\server.constant.php on line 4
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\glpi\files\_plugins\genericobject\fields\server.constant.php on line 4
Can someone please help me on this issue? Thanks.
Offline
Which GLPI and plugin version are you using?
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Thank you for replying, Conard!
I am currently using GLPI 10.0.7 and Generic Object plugin version 2.14.3
Offline
Do you have a locale file for this object which sets the value for $LANG['genericobject']['PluginGenericobjectServer'][1]?
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline
Apology for the late reply, Conard. Yes, I do. I saw that after the object has been created a locale file is created for it in the file path:
C:\xampp\htdocs\glpi\files\_plugins\genericobject\locales\server\server.en_US
I then added the additional code statement for adding a label for the custom field.
--------------------------------------------------------------------------------------------------------------
<?php
$LANG['genericobject']['PluginGenericobjectServer'][0]="server";
$LANG['genericobject']['PluginGenericobjectServer'][1]="Server Name"; // Define additional label
--------------------------------------------------------------------------------------------------------------
I also had just done a fresh installation of the Generic Object Management plugin to try the same procedure again. Though, this time I saw the option to add the custom field onto my object without the errors I showed above. However, the ID of the custom field is set by default to 'Type' for some reason? It would be nice if I could set the ID of the custom field to 'Server Name', for example.
Moreover, since the input type of the custom field is set to dropdown, I am able to add options for the dropdown list. When I clicked on the plus sign on the dropdown custom field. I received errors on the page as follows.
Warning
: Table glpi_plugin_genericobject_servertypes does not exists in
C:\xampp\htdocs\glpi\src\DBmysql.php
on line
1187
Warning
: Table glpi_plugin_genericobject_servertypes does not exists in
C:\xampp\htdocs\glpi\src\DBmysql.php
on line
1187
Warning
: Table glpi_plugin_genericobject_servertypes does not exists in
C:\xampp\htdocs\glpi\src\DBmysql.php
on line
1187
It seems that I have to add the custom field to GLPI's database. If this is the case, can you please guide me on where to add it in the 'DBmysql.php' file?
Last edited by BrandonJ (2023-06-16 06:07:58)
Offline
Sorry, I don't use this plugin and don't have more information on how to use it beyond the documentation.
However, it seems to me like you need to also add a custom object for your ServerType.
GLPI Collaborator and Plugin Developer.
My non-English comments are automated translations. Sorry for any confusion that causes.
Mes commentaires non anglais sont des traductions automatiques. Désolé pour toute confusion qui cause.
Mis comentarios que no están en inglés son traducciones automáticas. Perdón por cualquier confusión que cause.
Offline