Hi I have a number_field tag as follow:
<%= number_field :average_border, nil, min: 1, max: 4, :step => 'any', class: "number" %>
This number_filed tag is meant to be updated as pleased by the user with a number from 1 to 4.
I would like this tag to display the current value as a placeholder would do in a text field tag.
Thanks !
You can pass placeholder
attribute into it. But make sure you use the correct form helpers
if you are using form_tag
<%= number_field_tag :average_border, @current_value, min: 1, max: 4, :step => 'any', class: "number", placeholder: @hint_value %>
if you are using form_for
<%= f.number_field :average_border, min: 1, max: 4, :step => 'any', class: "number", placeholder: hint_value %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With