How to add a field to a form before submitting the form?

I am using a custom editor, that has its own style.

the only way to extract the data from the editor is through javascript.

How can I extract the data and add it to a form field before submitting the form?

You could extract it on/after changes being made in the editor, e.g. into a hidden input’s value, which would not only allow you to use phx-change, but also phx-submit as well.

1 Like

great, but I am not using liveview

The I‘d still suggest the same, as it‘s usually simpler to hook into editing lifecycles of the editor than trying to hook into form submission, which has a few footguns.

1 Like