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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fix dependency conflict with GLPI core by no longer vendoring symfony/deprecation-contracts and symfony/polyfill-ctype.
- Fix default field values not being applied when fields are empty on creation
- Fix mandatory fields blocking automated item creation
- Fix unclear mandatory field error when a GLPI form creating a ticket does not provide the field.

## [1.24.5] - 2026-09-11

Expand Down
12 changes: 10 additions & 2 deletions inc/container.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1669,10 +1669,11 @@ private static function isMandatoryCheckBypassed(array $data): bool
* @param array $data Data send by form
* @param string $itemtype Item type
* @param boolean $massiveaction ?
* @param boolean $is_creation True when validating a new item with nothing submitted
*
* @return boolean
*/
public static function validateValues($data, $itemtype, $massiveaction)
public static function validateValues($data, $itemtype, $massiveaction, $is_creation = false)
{
/** @var DBmysql $DB */
global $DB;
Expand Down Expand Up @@ -1775,6 +1776,13 @@ public static function validateValues($data, $itemtype, $massiveaction)
if ($empty_errors !== []) {
Session::AddMessageAfterRedirect(__('Some mandatory fields are empty', 'fields')
. ' : ' . implode(', ', $empty_errors), false, ERROR);
if ($is_creation) {
Session::AddMessageAfterRedirect(
__('The form or source creating this item does not provide the mandatory fields above: map them to it, or make them optional.', 'fields'),
false,
ERROR,
);
}
}

if ($number_errors !== []) {
Expand Down Expand Up @@ -2061,7 +2069,7 @@ private static function checkContainerMandatory(CommonDBTM $item, PluginFieldsCo
}
}

if (self::validateValues($data, $item::getType(), isset($_REQUEST['massiveaction'])) === false) {
if (self::validateValues($data, $item::getType(), isset($_REQUEST['massiveaction']), $item->isNewItem()) === false) {
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Units/ContainerItemUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,10 @@ public function testCreateIsBlockedWhenMandatoryDomFieldIsMissing(): void
__('Some mandatory fields are empty', 'fields'),
ERROR,
);
$this->hasSessionMessageThatContains(
__('The form or source creating this item does not provide the mandatory fields above: map them to it, or make them optional.', 'fields'),
ERROR,
);

// Creation with the mandatory field filled must succeed.
$ticket = new Ticket();
Expand Down
Loading