LiveView 1.0: ❌ phx-feedback-for | ✅ used_input?

Notes

LiveView 1.0 removes the phx-feedback-for annotation and introduces a new used_input?/2 helper instead!

LiveView 1.0 removes the client-based phx-feedback-for annotation for showing and hiding input feedback, such as validation errors. This has been replaced by Phoenix.Component.used_input?/2, which handles showing and hiding feedback using standard server rendering.

The used_input?/2 helper can now be used to do that. Check out this example copied from the docs:

<input type="text" name={@form[:title].name} value={@form[:title].value} />

<div :if={used_input?(@form[:title])}>
  <p :for={error <- @form[:title].errors}><%= error %></p>
</div>

<input type="text" name={@form[:email].name} value={@form[:email].value} />

<div :if={used_input?(@form[:email])}>
  <p :for={error <- @form[:email].errors}><%= error %></p>
</div>

The Phoenix team was nice enough to provide a shim library if you want to update to LiveView 1.0 without having to use the new used_input?/2 helper. And if you want to do it, they also provided a short upgrade guide in the changelog. Check it out!

Want the latest Elixir Streams in your inbox?

    No spam. Unsubscribe any time.