Please note :
It is important to know that this demo is not a
There is no
"store" as the source of the dynamic elements.
This demo shows how the
can be manipulated freely on the client side simply using the
"name" attributes on a traditional
We're going to provide a true
SPA demo in a near future.
tags and new
users and submit the form to see the validations in action! All existing field are required and have
a minimum length. Also,
tags must all be different in a given
HTMLtemplates (the frontend part) :
The explanation of this demo will be quite short. We encourage you to look at the source to see how it actually works!Basically, this demo shows how the fields of a traditional
HTMLform can be manipulate to change the underlying
form model. Spincast uses the
"name"attributes of the fields of a form to dynamically build a JsonObject representing this form.
When a form is submitted, we get a
JsonObject which represents it :
Form form = context.request().getFormOrCreate("demoForm"); context.response().addForm(form);
JsonObjectunder the hood!) depends on the
namesof the submitted fields. If you add or remove some fields client-side, the
formobject will reflect those modifications. This allows great flexibility when using traditional
Also, by adding back that dynamic
JsonObject to the
you can re-render the form and all the fields are kept, as they
Make sure you also try the first demo of this section, Introduction - Single field which introduces forms and validation using Spincast.
Otherwise, you can learn everything about forms and validation in the dedicated Forms section of the documentation.