Reputation: 11
For some cases, I'd like to have multiple lines in 'Submit' button value. I'm using Rails 6 and haml.
This is what I've came up with (don't work):
form_view.html.haml:
- if @count < 0
- check_btn_val = "Submit"
- else
- check_btn_val = "Submit<br>You have " + @count + " submissions remaining"
%input{"type" => "submit", "value" => check_btn_val, ...}
<br> is ignored and treated as plain text (button label contains "<br>" indside the value).
I've seen this question HTML: can I display button text in multiple lines? but I don't think this works for me, as it splits line based on fixed width of the button and my goal is to have break in specific place.
Upvotes: 1
Views: 503
Reputation: 11
Here's how I fixed it for my case:
- addtnl_txt = ""
- if @count >= 0
addtnl_txt = "You have $#{@count} submissions remaining"
%button{"type" => "submit", "value" => check_btn_val, ...}
Submit
%br
#{addtnl_txt}
Works nice, i.e. %br
is ignored if addtnl_txt
is empty
Upvotes: 0