Serialization

This demo covers the core serialization helpers that turn DOM form values and browser files into plain JavaScript objects. The helpers are intentionally simple. They do not create Tripous data objects; they prepare plain models that can later be posted, inspected, or passed to higher-level application code.

tp.ElementToProperty() reads one input, select, textarea, or button element and adds a property to a model object. tp.ContainerToModel() does the same for all matching child elements in a form or container. tp.ContainerToModelAsync() also includes file inputs by using tp.ReadFiles(). tp.PostModelAsForm() creates and submits a real HTML form, so this demo explains it but does not execute it live.

Sample form

The form contains common HTML controls. Property names come from name first and id second.

status
button

Form and element helpers

Use tp.ContainerToModel() for a whole form or container. Use tp.ElementToProperty() when you want to add just one element value to an existing model.

File helpers

tp.ReadFiles() reads browser File objects and returns tp.HttpFile objects. The demo creates a small in-memory file so no disk file is required.

Post as form

tp.PostModelAsForm() creates a temporary form, adds hidden inputs, submits it with POST, and removes the form later. It is useful for classic browser form posting, but it changes the current page, so the demo does not call it.

tp.PostModelAsForm("/orders/save", {
    Name: "John",
    Tags: ["core", "web"],
    Extra: { Level: 3 }
});