mardi 26 juillet 2016

Serialized form for javascript [on hold]

I need to manage a complex form entirely with Javascript.

I would not like to serve the entire form HTML markup to the user.

That's why I'd need to serialize the form so I can manipulate it with JS while the user fiddles with some HTML interactivity before submitting back to the server.

I saw this pretty old question and this "deprecated" bundle

The question is simple: How can I serialize a Symfony form's underlying data ?


Here was my first attempt, after having implemented JsonSerializable on the related objects:

{% form.vars.data|json_encode %}

But obviously this encodes the entire objects exposed properties

Aucun commentaire:

Enregistrer un commentaire