Setting default value in text_field/password_field

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| -%>

First Name
<%= f.text_field :firstname%>

...

Email
<%=f.text_field :email %>

Password
<%=f.password_field :password %>

...

<%= submit_tab 'Sign up' %>

<% end -%>

I would like to produce something of this type for both text_field and
password_field

Any ideas???

Hi, you should be able to do the following as stated in the Rails
Framework
Documentation:

<%= f.text_field :email, options => { :value => “[email protected]” }
%>

Good luck,

-Conrad

On 9/18/07, Will [email protected] wrote:

<%= f.text_field :firstname%>


I would like to produce something of this type for both text_field and
password_field

The initial values will be taken from @user, so populate that
(typically in the controller) before rendering your template.

@user = User.new(:email = “[email protected]”)
… then render the template

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs