Actor sheet -> working !!!
This commit is contained in:
@@ -64,6 +64,35 @@ export class VermineBaseActorSheet extends HandlebarsApplicationMixin(foundry.ap
|
||||
_canDragStart() { return this.isEditable }
|
||||
_canDragDrop() { return this.isEditable }
|
||||
|
||||
// ── Soumission du formulaire ────────────────────────────────────────
|
||||
|
||||
/** @override - coerce string values from HTML form inputs to numbers */
|
||||
_prepareSubmitData(submitData, form, formData) {
|
||||
const fd = foundry.utils.deepClone(formData.object)
|
||||
|
||||
for (const [key, value] of Object.entries(fd)) {
|
||||
if (!key.startsWith("system.") || typeof value === "number") continue
|
||||
|
||||
const segments = key.slice(7).split(".")
|
||||
let node = this.document.system.schema
|
||||
for (const seg of segments) {
|
||||
if (node instanceof foundry.data.fields.SchemaField) node = node.fields[seg]
|
||||
else { node = undefined; break }
|
||||
}
|
||||
if (!(node instanceof foundry.data.fields.NumberField)) continue
|
||||
|
||||
// Handle arrays from duplicate-named form inputs
|
||||
let raw = Array.isArray(value) ? value.filter(v => v !== "" && v !== null).pop() : value
|
||||
if (raw === undefined) continue
|
||||
if (typeof raw === "string" && raw.trim() === "") { fd[key] = 0; continue }
|
||||
|
||||
const num = Number(typeof raw === "string" ? raw.trim() : raw)
|
||||
if (!isNaN(num)) fd[key] = num
|
||||
}
|
||||
|
||||
return fd
|
||||
}
|
||||
|
||||
// ── Contexte commun ─────────────────────────────────────────────────
|
||||
|
||||
async _prepareContext() {
|
||||
|
||||
Reference in New Issue
Block a user