Monday, May 20, 2024
96
rated 0 times [  98] [ 2]  / answers: 1 / hits: 16634  / 10 Years ago, sun, january 25, 2015, 12:00:00

Could someone show me how to set the size of number_field in rails? I tried this but it doesn't work:



<%= f.number_field :status, size: 10, ...


but this works:



<%= f.text_field :name, size: 10, ...


Thanks


More From » ruby-on-rails

 Answers
57

You need to use :max option.


<%= f.number_field :name, max: 10, .. %>

Read the documentation number_field_tag.



number_field_tag(name, value = nil, options = {})


Creates a number field.



Options



  • :min - The minimum acceptable value.



  • :max - The maximum acceptable value.



  • :in - A range specifying the :min and :max values.



  • :step - The acceptable value granularity.




[#68094] Friday, January 23, 2015, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
allans

Total Points: 336
Total Questions: 120
Total Answers: 119

Location: Peru
Member since Mon, Jun 6, 2022
2 Years ago
;