问题
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