hello
anyone know how i can set a default integer value with simple_form, i
have code like this below in my view but its not working.

<%= f.input :age, :value => '30' %>

i would like the input box to have the value of 30 by default
thanks for any help.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Bill Walton at Jan 7, 2012 at 7:31 pm
    Hello Brent,
    On Sat, Jan 7, 2012 at 1:17 PM, brent brent wrote:
    hello
    anyone know how i can set a default integer value with simple_form, i
    have code like this below in my view but its not working.

    <%= f.input :age, :value => '30' %>

    i would like the input box to have the value of 30 by default
    thanks for any help.
    If I understand your intent, it has nothing to do with simple_form.
    Either a migration-based default value for the database field or a
    model-based, after_create filter could be used to set the initial
    value of the age field in a newly-created instance of the object.
    That, in turn, will have the result that it appears to me you're
    trying to achieve.

    HTH,
    Bill

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Ahmy Yulrizka at Jan 8, 2012 at 6:10 am
    <%= f.input :name, :input_html => { :value => 'test'} %>

    Ahmy Yulrizka

    On Sun, Jan 8, 2012 at 2:31 AM, Bill Walton wrote:

    Hello Brent,
    On Sat, Jan 7, 2012 at 1:17 PM, brent brent wrote:
    hello
    anyone know how i can set a default integer value with simple_form, i
    have code like this below in my view but its not working.

    <%= f.input :age, :value => '30' %>

    i would like the input box to have the value of 30 by default
    thanks for any help.
    If I understand your intent, it has nothing to do with simple_form.
    Either a migration-based default value for the database field or a
    model-based, after_create filter could be used to set the initial
    value of the age field in a newly-created instance of the object.
    That, in turn, will have the result that it appears to me you're
    trying to achieve.

    HTH,
    Bill

    --
    You received this message because you are subscribed to the Google Groups
    "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to
    rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at
    http://groups.google.com/group/rubyonrails-talk?hl=en.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 7, '12 at 7:17p
activeJan 8, '12 at 6:10a
posts3
users3
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2022 Grokbase