user1085536
user1085536

Reputation:

set value on textfield

In my application I want set value to textfield. I want to do same like here

<input type="text" value ="something">

My question how could i do the same on rails view.

   <h1>New location</h1>

<% form_for(@location) do |f| %>
  <%=  f.error_messages %>

  <p>
    <%= f.label :address %><br />
    <%=  f.text_field :address %>

  </p>
  <p>
    <%= f.label :latitude %><br />
    <%= f.text_field :latitude %>
  </p>
  <p>
    <%= f.label :longitude %><br />
    <%= f.text_field :longitude %>
  </p>
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>

<%= link_to 'Back', locations_path %>

Upvotes: 3

Views: 2932

Answers (1)

Kulbir Saini
Kulbir Saini

Reputation: 3915

By passing the value argument

<%= f.text_field :latitude, :value => 17 %>

Upvotes: 5

Related Questions