Storing a generated value in a phoenix form

The sequence of actions is:
1- the user clicks a button
2- some processing is done and a value is generated (through a client-side script)
?- how do I store this generated value?

Should I dispatch an event to the liveview module through the client-side script?

Probably need a bit more detail on the problem you are trying to solve. But yes, you can use pushEvent to send data generated through client-side Javascript back to the LiveView process on the server. In fact, there was a thread about this very thing a week ago:

1 Like

You might be able to add a hidden field on the form that you ask Phoenix to ignore, put your generated value in it and then it will/might get sent to the server when you submit.

You could also put it in a field with phx-value-...=..., with phx-update="ignore" on the field too.

1 Like

the generated value (conditionally) needs to insert new fields to the form, so this might be in another case