开发者

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".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜