Saturday, January 7, 2012

Re: [Rails] set a default value with simple_form

<%= f.input :name, :input_html => { :value => 'test'} %>

Ahmy Yulrizka


On Sun, Jan 8, 2012 at 2:31 AM, Bill Walton <bwalton.im@gmail.com> wrote:
Hello Brent,

On Sat, Jan 7, 2012 at 1:17 PM, brent brent <lists@ruby-forum.com> 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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate