Enter won't submit form

Hello there!

I’m learning Phoenix while creating a simple chat app. So far I wrote a text input to submit my messages but for some reason, when pressing enter absolutely nothing happens, no event is triggered at all. The text input is written like this:

    <% f = form_for :chat, "#", id: "chat-form", phx_submit: :send_message %>
        <%= text_input f, :message, placeholder: "Type your message" %>

The browser console also shows nothing. Can anyone help me with this?


I think you might need a submit button in your form for Enter to be picked up. You can hide it if needed:

<input type="submit" style="display: none" />

thanks for the answer! I tried this exact piece of code and I’ve also tried adding this:
<<%= submit "Send message" %>>
But neither of the options worked for me, clicking on the button or pressing enter won’t submit the form

Solved, it was missing an = on the first line:
<%= f = form_for :chat, "#", id: "chat-form", phx_submit: :send_message %>