Skip to content

Conversation

mdiazgoncalves
Copy link

The getNameField() method returns 'label' instead of 'name', so the CommonDBTM logic does not render a link.

Bug Description

When viewing the list of blocks in Setup → Plugins → Fields → Blocks, the column Name shows plain text instead of a clickable link to edit the block.

Expected behavior:
Each block name should appear as a clickable hyperlink to the block’s form.

Steps to Reproduce

  1. Go to Setup → Plugins → Fields → Blocks
  2. View the list of existing blocks
  3. Observe that the “Name” column is not clickable

Expected Result

The “Name” column should contain clickable links leading to the edit form of each block.

Root Cause

In inc/container.class.php, the method:

public static function getNameField()
{
    return 'label';
}

The rawSearchOptions() method defines:

[
 'id'            => 1,
 'table'         => self::getTable(),
 'field'         => 'name',
 'name'          => __('Name'),
 'datatype'      => 'itemlink',
 'itemlink_type' => self::getType(),
 'massiveaction' => false,
]

Because getNameField() returns 'label' instead of 'name', the GLPI core (CommonDBTM) does not render the itemlink as a hyperlink.

Proposed Fix

Option 1 (Applied)

Change the return value of getNameField():

public static function getNameField()
{
    return 'label';
}

Option 2 (Alternative)

Modify rawSearchOptions():

'field' => self::getNameField(),

Either option restores proper linking behavior.

Result

After applying the fix, the block name is displayed as a clickable link that opens the block edit form.

The getNameField() method returns 'label' instead of 'name', so the CommonDBTM logic does not render a link.
@stonebuzz
Copy link
Contributor

The container does include a label field.

When you create an “Asset infor” container, the value is stored in the “Label” column.

This value is then sanitized and saved in the “Name” column.

This field is used internally by the plugin, which is why we force GLPI to display the value from the “Label” field instead of the “Name” field.

It seems that, in your case, the “Label” column might be empty in the database.

Could you please check this?

@mdiazgoncalves
Copy link
Author

mdiazgoncalves commented Oct 7, 2025

All label values are correctly filled.

MariaDB [glpi]>
SELECT id, name, label -> FROM glpi_plugin_fields_containers -> ORDER BY id;
+----+--------------------+------------------------+
| id | name | label |
+----+--------------------+------------------------+
| 1 | basededado | basededado |
| 2 | certificado | certificado |
| 3 | fundamentacao | Fundamentacao |
| 4 | ccntwo | CCN2 |
| 11 | ativoscriptogrfico | Ativos criptográficos |
+----+--------------------+------------------------+
5 rows in set (0.002 sec)

The suggested change was the only way to make the block name display as a clickable link in the list view.
Even with the label values correctly populated, GLPI did not generate the hyperlink when using label as the reference field.

Anyway, I will perform additional tests on a fresh installation to confirm the default behavior and will get back with the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants