LiveView form resets String:Array field on focus out

I have used the generator to build a simple form containing an string array.

Then I’m editing it using:


  <%= label f, :parts %>
    <%= for part <- do %>  
    <input name="post[parts][]" value={part} />
  <% end %>

it works and correctly saves the changes to DB.

nonetheless, if I edit one input, the others reset to their original value.

So I started digging and checking what the changeset coming to the backend contains, checked no validation error was being generated and finally I concluded this: changing be content of the inputs triggers the “validate” event and it forces a redraw of the form, wiping out the modifications done until then

Weirdly enough the liveview diff coming for rerendering over websocket is huge, maybe it’s not possible to use “for” in the forms of liveview because it breaks the diffing engine?

Your .form mentions a @changeset, but the loop that generates the part inputs uses @post. Can you show the code that connects them together (likely in your handle_event("validate", ...) function)?