fix for single file saving

Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
Andy Miller
2026-03-24 16:18:07 -06:00
parent e7fb97ca3a
commit eb3cc2e9d1

View File

@@ -769,8 +769,13 @@ class AdminBaseController
} elseif ($obj instanceof UserInterface and $key === 'avatar') {
$obj->set($key, $files);
} else {
// TODO: [this is JS handled] if it's single file, remove existing and use set, if it's multiple, use join
$obj->join($key, $files); // stores
// For single file fields, replace existing value to prevent stale file entries
$fieldSettings = $obj->blueprints()->schema()->getProperty($key);
if (is_array($fieldSettings) && empty($fieldSettings['multiple'])) {
$obj->set($key, $files);
} else {
$obj->join($key, $files);
}
}
}