Rails number_field tag placeholder?
Hi I have a number_field tag as shown below:
<%= number_field :average_border, nil, min: 1, max: 4, :step => 'any', class: "number" %>
This number_filed tag should be updated as requested by the user numbered 1 through 4.
I would like this tag to display the current value as a placeholder in the textbox tag.
Thank!
+3
source to share
1 answer
You can pass an attribute to it placeholder
. But make sure you are using the correct oneform helpers
if you use form_tag
<%= number_field_tag :average_border, @current_value, min: 1, max: 4, :step => 'any', class: "number", placeholder: @hint_value %>
if you use form_for
<%= f.number_field :average_border, min: 1, max: 4, :step => 'any', class: "number", placeholder: hint_value %>
+8
source to share