Rails simpleform pre data
How do I make a simple form association have pre data when editing?
My form:
<h1>Editing kategori</h1>
<%= simple_form_for(@konkurrancer, :url => {:action => 'update', :id => @konkurrancer.id }) do |f| %>
<%= f.association :kategoris %>
<%= f.butto开发者_开发知识库n :submit, :value => 'Edit konkurrence' %>
<% end %>
You almost did it:
<%= f.button :submit, :value => 'Edit konkurrence', :data_pre => "whatever here" %>
Your best bet is to do something like this in your controller:
def edit
@konkurrancer = Konkurrancer.new(:title => "hello wurld", :description => "blah blah blah", :nuclear_level => 10)
end
Then your form should automatically populate these values as "pre data".
精彩评论