使用ActiveAdmin的多步骤表单? [英] Multistep form with ActiveAdmin?

查看:63
本文介绍了使用ActiveAdmin的多步骤表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用ActiveAdmin创建多步骤表单?

Is it possible to create a multistep form with ActiveAdmin?

如果没有,是否可以添加提交表单后重定向到的另一个页面(一个

If not, is it possible to just add another page that it redirects to after submitting the form (one that is not the default index, show or form pages)?

推荐答案

我一直很担心这个问题。我发现您可以使用ActiveAdmin文件中的收集操作来添加自己的页面。假设您的模型名为MyModel,您可以将其添加到ActiveAdmin my_model.rb文件中。

I've been fretting with this issue myself. I found that you can add your own pages using collection actions in your ActiveAdmin file. Say your model is called MyModel, you would add this to your ActiveAdmin my_model.rb file.

# GET /admin/my_model/page1
collection_action :page1, :method => :get do
  render 'admin/page1'
end

# POST /admin/my_model/page1
collection_action :page1, :method => :post do
  # Do your form processing
  redirect_to test_admin_my_model_path
end

# GET /admin/my_model/page2
collection_action :page2, :method => :get do
  render 'admin/page2'
end

然后需要在/app/views/admin/page1.html.erb和page2.html.erb

You would then need to create a view at /app/views/admin/page1.html.erb and page2.html.erb

这篇关于使用ActiveAdmin的多步骤表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆