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

functional components, such as .form do not support ":on_[event]" directive #6

Open
derek-zhou opened this issue Oct 2, 2024 · 0 comments

Comments

@derek-zhou
Copy link

derek-zhou commented Oct 2, 2024

Describe the bug

After 0.12.0, Form is deprecated; users are supposed to convert to the plain live_view functional component .form. However, .form does not convert the surface event; so it is a bit awkward now to use forms.

Edit: Oops, I should have filed the issue against surface, not surface_form_helpers

How to reproduce it

<.form :on-submit={@submit} ...>

does not work. @submit is a Surface event, not a string, so it cannot serialize to HTML.

<.form :on-submit={@submit.name} ...>

does not work either; the :on-submit is passed through to html without conversion.

I have to do this:

<.form phx-submit={@submit.name} ...>

Which is less than optimal. BTW: the :if={} directive works for .form

I like functional components, they can be considered as a light weight version of components (no hooks, no css...). However, their usage need to be normalized with module components and html tags to avoid confusion for developers.

Your Environment

Surface: v0.12.0
LiveView: v0.20.12
Elixir: v1.15

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