我有activeadmin表格
> f.input :title, label: 'Title', :input_html =>{ :required => ''} li
> do
> f.label :location
> f.select :location, options_for_select([['Community', 'Community'], ['Learn More', 'Learn More']]), :prompt => "Select
> Location" ,:collection => displayable_collection end li do
> f.label :Type
> f.select :content_type, options_for_select([['Article', 'Article'], ['Gallery', 'Gallery'], ['Video', 'Video']]), :prompt =>
> "Select Type", :id => 'content_type' end
当表单提交并且出现错误时,表单内容没有值,如果出现错误我想填写表单。
答案 0 :(得分:0)
尝试,
f.input :title, label: 'Title', :input_html =>{ :required => '', :value => f.object.title}
do
f.label :location
f.select :location, options_for_select([['Community', 'Community'], ['Learn More', 'Learn More']], :selected => f.object.location), :prompt => "Select Location" ,:collection => displayable_collection end li do
f.label :Type
f.select :content_type, options_for_select([['Article', 'Article'], ['Gallery', 'Gallery'], ['Video', 'Video']], :selected => f.object.content_type), :prompt => "Select Type", :id => 'content_type'
end
它不是,f对象持有的实例值。这就是我写f.object
的原因。您可以直接使用instacen,例如@user.location