I have activeadmin form
> 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
when form is submit and error come , form filed content no value, I want to populate form if error comes.
try with,
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
Its not, what instance value f object is holding. That's why i have written f.object
. You can directly use instacen like, @user.location
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.