Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle form_for in liveview #6

Closed
adamzapasnik opened this issue Jan 28, 2021 · 2 comments · Fixed by #16
Closed

Handle form_for in liveview #6

adamzapasnik opened this issue Jan 28, 2021 · 2 comments · Fixed by #16
Assignees
Labels
bug Something isn't working

Comments

@adamzapasnik
Copy link
Owner

https://hexdocs.pm/phoenix_html/Phoenix.HTML.Form.html#module-phoenix-liveview-integration

<%= f = form_for @changeset, url, opts %>
  <%= text_input f, :name %>
</form>

The only way to fix it right now, it to replace <%= form_for %> with <form> and at the end replace it again with the original expression.

Other solution would be to add do at the end of form_for expression and replace </form> with <% end %> before encoding step. I actually prefer this, because it wouldn't require too many changes in encoder/decoder.

@adamzapasnik adamzapasnik added the bug Something isn't working label Jan 28, 2021
@adamzapasnik adamzapasnik self-assigned this Feb 9, 2021
@dnsbty
Copy link
Contributor

dnsbty commented Feb 10, 2021

I was just coming to report this. I would be happy to help if I knew how to fix it. I'm trying to understand your other solution though. If I try to use a do block with the form I get a compile error: undefined function f/0

I've temporarily fixed it like this:

<% f = form_for @changeset, "#" %>
<form action="#" id="change_email_form" method="post" phx-submit="update_email">
  ...
</form>

I don't love it though.

@adamzapasnik
Copy link
Owner Author

I have a working solution, I need to wrap it up and release. Will try to do it today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants