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

Surface LiveComponent raise single static root error if render root is Form Component #746

Closed
Dylan-aidkr opened this issue Apr 18, 2024 · 2 comments

Comments

@Dylan-aidkr
Copy link

Dylan-aidkr commented Apr 18, 2024

Describe the bug

if i use Form component in Surface Live Component, it raises 'Stateful components must have a single static HTML tag at the root' error

How to reproduce it

use MyWeb, :surface_live_component

def render(assigns) do
    ~F"""
    <Form class={["form-table-row"]}>
      <div>
        hello
      </div>
    </Form>
    """
end

Your Environment

Surface: v0.11.4
LiveView: v0.20.14
Elixir: v1.15.5 (compiled with Erlang/OTP 26)

@Dylan-aidkr Dylan-aidkr changed the title Surface LiveComponent raise 'Stateful components must have a single static HTML tag at the root' Surface LiveComponent raise single static root error if root is Form Component Apr 18, 2024
@Dylan-aidkr Dylan-aidkr changed the title Surface LiveComponent raise single static root error if root is Form Component Surface LiveComponent raise single static root error if render root is Form Component Apr 18, 2024
@dougw-bc
Copy link

You need a static node at the root of a live component, like a div

~F"""
 <div>
  <Form class={["form-table-row"]}>
    <div> hello </div>
  </Form>
 </div>
"""

Unrelated, but Form is being deprecated, so might want to write new code without it, and just use the phoenix form/1 component.

@Dylan-aidkr
Copy link
Author

I misunderstood the meaning of static node until now.
for some styling requirements, I couldn't simply wrap it with a div. I will try phoenix form/1 instead.
Thank you for the answer.

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

2 participants