You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2023-01-05 14:40:32

Samuel33190
Member
Registered: 2022-08-17
Posts: 4

Documentation plugin

Bonjour,

Sur la documentation : glpi-developer-documentation.readthedocs.io/en/master/plugins/objects.html

Dans l'exemple du fichier : inc/myobject.class.php

A quoi correspond la fonction autoName à la ligne 21 ?

<?php
class PluginMyExampleMyObject extends CommonDBTM {
   public function showForm($ID, $options = []) {
      global $CFG_GLPI;

      $this->initForm($ID, $options);
      $this->showFormHeader($options);

      if (!isset($options['display'])) {
         //display per default
         $options['display'] = true;
      }

      $params = $options;
      //do not display called elements per default; they'll be displayed or returned here
      $params['display'] = false;

      $out = '<tr>';
      $out .= '<th>' . __('My label', 'myexampleplugin') . '</th>'

      $objectName = autoName(
         $this->fields["name"],
         "name",
         (isset($options['withtemplate']) && $options['withtemplate']==2),
         $this->getType(),
         $this->fields["entities_id"]
      );

      $out .= '<td>';
      $out .= Html::autocompletionTextField(
         $this,
         'name',
         [
            'value'     => $objectName,
            'display'   => false
         ]
      );
      $out .= '</td>';

      $out .= $this->showFormButtons($params);

      if ($options['display'] == true) {
         echo $out;
      } else {
         return $out;
      }
   }
}

Last edited by Samuel33190 (2023-01-05 14:40:54)

Offline

Board footer

Powered by FluxBB