多个提交选项与向导窗体和邪恶的宝石 [英] Multiple Submit Options with wizard form and Wicked gem

查看:161
本文介绍了多个提交选项与向导窗体和邪恶的宝石的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了文档,但似乎无法找出我的问题。



我有一个多页向导窗体,并且在这个页面上有4个按钮。

我需要每个按钮来更新并且同时提交表单。



我试图用4个不同的提交按钮来做这件事,但不成功。我认为最好的办法是制作一个自定义的url并传入参数,但不知道如何用Wicked做到这一点。



示例

  [button_a] => wizard_path,{option:a} 
[button_b] => wizard_path,{option:b}
[button_c] => wizard_path,{option:c}
[button_d] => wizard_path,{option:d}


解决方案

最容易使用轨道 button_to 助手

  = button_to('Update A',wizard_path(@wizard,option:'a'),method:put)
= button_to('Update B',wizard_path(@wizard,option:'b'),method:put)
= button_to('Update C',wizard_path(@wizard,option:'c '),method:put)
= button_to('Update D',wizard_path(@wizard,option:'d'),method:put)

您从控制器获得的参数可能类似于

  params {id:123,option:'a'} 

是在向导#123


上按下了按钮A

I looked at Wicked documentation, but can't seem to figure out my problem.

I have a multipage wizard form, and on this page I have 4 buttons.

I need each button to update a specific attribute in my model, and also submit the form at the same time.

I tried to do this with 4 different submit buttons unsuccessfully. I think the best way to do it would be to have a custom url and pass in a param, but not sure how to do this with Wicked.

Example

[button_a] => wizard_path, {option: "a"}
[button_b] => wizard_path, {option: "b"}
[button_c] => wizard_path, {option: "c"}
[button_d] => wizard_path, {option: "d"}

解决方案

It would be easiest to use the rails button_to helper

= button_to('Update A', wizard_path(@wizard, option: 'a'), method: "put" )
= button_to('Update B', wizard_path(@wizard, option: 'b'), method: "put" )
= button_to('Update C', wizard_path(@wizard, option: 'c'), method: "put" )
= button_to('Update D', wizard_path(@wizard, option: 'd'), method: "put" )

The params you get from the controller, would be something like

params { id: 123, option: 'a' }

From there all you know is that button "A" was pressed on the wizard #123

这篇关于多个提交选项与向导窗体和邪恶的宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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