Multiple Submit Options with wizard form and Wicked gem

时光怂恿深爱的人放手 提交于 2020-01-25 11:31:46

问题


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

回答1:


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



来源:https://stackoverflow.com/questions/21099822/multiple-submit-options-with-wizard-form-and-wicked-gem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!