Reputation:
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
Reputation: 3915
By passing the value
argument
<%= f.text_field :latitude, :value => 17 %>
Upvotes: 5