Why Surface component used in .heex doesn't validate props?

Hello folks!
I have surface stateless component that look like that

defmodule MyApp.Components.PasswordInput do
  use Surface.Component
  use MyApp, :surface_view

  prop f, :form, required: true
  prop field, :atom, default: :password
  prop label, :string, default: "Password"

  def render(assigns) do
    ... some content 

I try to use it in my .heex template served by Phoenix.Controller next way

<MyApp.Components.PasswordInput.render f={f} />

But looks like default values for properties doesn’t work, as well as any other options.
I have couple of questions:

  • Can Surface component be used in .heex template with all available features?
  • Can Surface component be rendered directly from Phoenix Controller?

How do you expect liveview to know how surface works? Surface is a compiler built on top of Liveview. Please see the docs on this issue:


1 Like