I am trying to set a default value in a text_field form. I know how to do this in html, but is there a way to do this with form_for Here is my code <% form_for :user do |f| -%> <p><label for="firstname"%>First Name</label><br/> <%= f.text_field :firstname%></p> ... <p><label for ="email"%>Email</label><br/> <%=f.text_field :email %></p> <p><label for="password"%>Password</label><br/> <%=f.password_field :password %></p> ... <p><%= submit_tab ''Sign up'' %></p> <% end -%> I would like to produce something of this type for both text_field and password_field <input type="text" name = "email" value="something-ejp3exJ1mLY@public.gmane.org" method="post"> Any ideas??? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Conrad Taylor
2007-Sep-18  20:18 UTC
Re: Setting default value in text_field/password_field
Hi, you should be able to do the following as stated in the Rails Framework
Documentation:
<%= f.text_field :email,  options => { :value =>
"something-ejp3exJ1mLY@public.gmane.org" } %>
Good luck,
-Conrad
On 9/18/07, Will
<william_evanson-Cdg0nuESRUEQi57izRGoj0EOCMrvLtNR@public.gmane.org>
wrote:>
>
> I am trying to set a default value in a text_field form.  I know how
> to do this in html, but is there a way to do
> this with form_for
>
> Here is my code
>
> <% form_for :user do |f| -%>
>
> <p><label for="firstname"%>First
Name</label><br/>
> <%= f.text_field :firstname%></p>
> ...
> <p><label for
="email"%>Email</label><br/>
> <%=f.text_field :email %></p>
>
> <p><label
for="password"%>Password</label><br/>
> <%=f.password_field :password %></p>
> ...
> <p><%= submit_tab ''Sign up'' %></p>
> <% end -%>
>
> I would like to produce something of this type for both text_field and
> password_field
> <input type="text" name = "email"
value="something-ejp3exJ1mLY@public.gmane.org"
> method="post">
> Any ideas???
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Bob Showalter
2007-Sep-18  20:18 UTC
Re: Setting default value in text_field/password_field
On 9/18/07, Will <william_evanson-Cdg0nuESRUEQi57izRGoj0EOCMrvLtNR@public.gmane.org> wrote:> > I am trying to set a default value in a text_field form. I know how > to do this in html, but is there a way to do > this with form_for > > Here is my code > > <% form_for :user do |f| -%> > > <p><label for="firstname"%>First Name</label><br/> > <%= f.text_field :firstname%></p> > ... > <p><label for ="email"%>Email</label><br/> > <%=f.text_field :email %></p> > > <p><label for="password"%>Password</label><br/> > <%=f.password_field :password %></p> > ... > <p><%= submit_tab ''Sign up'' %></p> > <% end -%> > > I would like to produce something of this type for both text_field and > password_field > <input type="text" name = "email" value="something-ejp3exJ1mLY@public.gmane.org" > method="post">The initial values will be taken from @user, so populate that (typically in the controller) before rendering your template. @user = User.new(:email = "something-ejp3exJ1mLY@public.gmane.org") ... then render the template --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---