Reputation: 569
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 !
Upvotes: 4
Views: 4329
Reputation: 5958
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 %>
Upvotes: 11