Placeholder doesn't work when {@rest} is passed to a custom function component

Hi all,
I’m trying to create an input textarea function component. Just as in core_components, I’ve defined rest as an attribute with global fields (This list includes placeholder).
However, when I call the component with the placeholder <.Component placeholder="Email" /> the placeholder isn’t rendered.

This is my code-

            id={@id || @name}
          ><%= Phoenix.HTML.Form.normalize_value("textarea", @value) %></textarea>

To fix this, I passed placeholder={@placeholder} separately, and it seems to be working.

Any idea what I’m doing wrong?

Hello and welcome!

Could you please share the whole component definition including the attrs and any slots. It’s impossible to tell without seeing it since the bit you did share looks fine. You could just have a typo or something.

I’m also not quite sure what you mean when you say you pass placeholder={@placeholder} “separately”. Separately from what?

1 Like

Thanks for the immediate reply!

I tried to find out what’s causing the error by passing using dbg/2 function
I noticed that target=[undefined] was being logged everytime
So, I assigned name=“form” to the <.simple_form> and it suddenly started working. Not sure why I had to assign a name though

Never assigned a name for the form when working with <.input /> from core_components.ex and it used to work pretty fine
Thanks a ton! My issue is resolved