Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ajax/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@

$display_condition = new PluginFieldsContainerDisplayCondition();
if ($display_condition->computeDisplayContainer($item, $containers_id)) {
$field_options = [
'label_class' => 'col-lg-3',
'input_class' => 'col-lg-9',
];
echo "<div class='offset-md-1 col-md-8 col-xxl-6'>";
PluginFieldsField::showDomContainer(
$containers_id,
$item,
$type,
$subtype,
$field_options,
);
echo "</div>";
Comment on lines +59 to +71

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapper is now always applied on AJAX refresh, but showForTab (inc/field.class.php:965-974) only applies it for helpdesk.public.php/tracking.injector.php. Normal admin/agent forms load with no wrapper, then get re-wrapped as soon as any field changes ; fields shift after the first edit. Matches misalignment reports on the PR thread (e.g. leeopereira, 2025-08-28).

Should this only apply when $type/$subtype matches the public/injector context, like showForTab?

} else {
echo '';
}
Expand Down
10 changes: 8 additions & 2 deletions inc/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,12 @@ public static function showForTab($params)
{
$item = $params['item'];

if ($item->fields['type'] == "") {
$item->fields['type'] = $params['options']['type'];
}
if ($item->fields['itilcategories_id'] == "") {
$item->fields['itilcategories_id'] = $params['options']['itilcategories_id'];
}
Comment on lines +890 to +895

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

post_item_form is a global hook, fired for all 70+ itemtypes, not just Ticket. Most have no type/itilcategories_id column (even Change/Problem lack type), so this raises "Undefined array key" warnings on nearly every item's edit form.

Suggested change
if ($item->fields['type'] == "") {
$item->fields['type'] = $params['options']['type'];
}
if ($item->fields['itilcategories_id'] == "") {
$item->fields['itilcategories_id'] = $params['options']['itilcategories_id'];
}
if ($item instanceof Ticket) {
$item->fields['type'] = $item->fields['type'] ?: ($params['options']['type'] ?? '');
}
if ($item instanceof CommonITILObject) {
$item->fields['itilcategories_id'] = $item->fields['itilcategories_id'] ?: ($params['options']['itilcategories_id'] ?? '');
}

Can you test with a non-ITIL item (e.g. Computer)? No test covers this method.

$functions = array_column(debug_backtrace(), 'function');
$subtype = isset($_SESSION['glpi_tabs'][strtolower($item::getType())]) ? $_SESSION['glpi_tabs'][strtolower($item::getType())] : '';
$type = substr($subtype, -strlen('$main')) === '$main'
Expand Down Expand Up @@ -956,7 +962,7 @@ public static function showForTab($params)
}

$html_id = 'plugin_fields_container_' . mt_rand();
if (strpos($current_url, 'helpdesk.public.php') !== false) {
if (strpos($current_url, 'helpdesk.public.php') !== false || strpos($current_url, 'tracking.injector.php') !== false) {
echo "<div id='{$html_id}' class='card-body row mx-0' style='border-top:0'>";
echo "<div class='offset-md-1 col-md-8 col-xxl-6'>";
$field_options = [
Expand All @@ -976,7 +982,7 @@ public static function showForTab($params)
$field_options ?? [],
);
}
if (strpos($current_url, 'helpdesk.public.php') !== false) {
if (strpos($current_url, 'helpdesk.public.php') !== false || strpos($current_url, 'tracking.injector.php') !== false) {
echo '</div>';
}
echo '</div>';
Expand Down
Loading