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

undefined function form/1 #337

Closed
jcsrb opened this issue Jun 27, 2022 · 1 comment
Closed

undefined function form/1 #337

jcsrb opened this issue Jun 27, 2022 · 1 comment

Comments

@jcsrb
Copy link

jcsrb commented Jun 27, 2022

I added torch to an existing phoenix app and got this issue when compiling

== Compilation error in file lib/myapp_web/views/post_view.ex ==
** (CompileError) lib/myapp_web/templates/post/form.html.heex:1: undefined function form/1 (expected MyAppWeb.PostView to define such a function or for it to be imported, but none are available)

I think this is because the origin of the my app was in phoenix 1.5 without liveview that later was upgraded to 1.6 and therefor my MyAppWeb didn't have

# Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)
import Phoenix.LiveView.Helpers

in defp view_helpers

adding import Phoenix.LiveView.Helpers made it work as expected

I and creating and closing this issue for documentation reason in case someone else hits this
thanks

@jcsrb jcsrb closed this as completed Jun 27, 2022
@jcsrb
Copy link
Author

jcsrb commented Dec 12, 2022

for phoenix_live_view > 0.18 that needs to be import Phoenix.Component
https://github.com/phoenixframework/phoenix_live_view/blob/master/CHANGELOG.md#0180-2022-09-20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant