Skip to content

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

Open
@derek-zhou

Description

@derek-zhou

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions