Textbox wrap


I have a text box in chat . when i am sending long sentences in just keep on taking the text to right and letting me add more text. I want to wrap the text when it reaches the end of the text box…
please let me know how can i do :slight_smile:
Following is the code snippet:

<%= f = form_for :message, "", method: "post" %> <%= text_input f, :body, placeholder: "Start typing to send message", required: true %>
    <%= submit "Send Message", class: "btn btn-primary2 btn-small" %>
  <%= if get_flash(@conn, :error_m) do %>
    <div class='text-red'><%= get_flash(@conn, :error_m) %></div>
  <% end %>
  <div class='text-notice text-grey'>Note: You must refresh this page to see new messages.</div>

<input type="text"> cannot be multi line. Only <textarea> can be. Automatic wrapping of text / resizing of the textarea for the available text is something you need javascript for. HTML doesn’t do that for you.

how can i use text area in elixir…
currently i am using
<%= text_input f, :body, placeholder: “Start typing to send message”, required: true %>


I have added this… but it is not increasing the height of text box…

Nothing related to Phoenix, it’s just HTML…


See the attributes rows and cols

But i am not able to give attribute rows with text area:
<%= textarea f, :body, placeholder: “Start typing to send message”, required: true, rows:“5” %>

Like this…

html_opts: [rows: 5, required: true]

You are also not supposed to specify them as strings but at integers, as @kokolegorille shows you.

no luck… i tried !!! its giving me error:

<%= textarea f, :body, placeholder: “Start typing to send message” ,opts [rows:5, required: true] %>

This is not what I have written!

:thinking: :thinking: :thinking:

html_opts: [rows: 5, required: true]

You think it’s equal?

opts [rows:5, required: true]

Perhaps also tell us what error you see…

The error is probably opts is not defined…

Probably, still it was a tip for the OP to not only show code thats not working but the error as well. In this case its pretty obvious but there are cases when its not and the error message helps a lot.


actually i tried using html_opts then i replaced with opts:
following is the error with this code :
<%= textarea f, :body, placeholder: “Start typing to send message” ,html_opts: [rows: 5, required: true]%>

lists in Phoenix.HTML and templates may only contain integers representing bytes, binaries or other lists, got invalid entry: {:rows, 5}

I am sorry, but my brain is not working properly… html_opts will not work in your case. Because it’s coming from some helpers of mine…

Did You try the simple form?

<%= textarea f, :body, placeholder: “Start typing to send message” , rows: 5, required: true %>

i did try this but no use!! it just keep on adding scroller in text box but not able to increase the height of text box

You mean you want to dynamically increase the height of the text area as the user types in it?