1

I'm making an app where I have multiple forms on one page but they are all similar; there is a text box and a submit button.

What I would like to do is consolidate all text boxes into one then have many submit buttons. That way the user inputs the data once in the obvious text box at top then decides which category (submit button) he would like to apply the data in the input box to.

Is this possible? I can't find and documentation on how to do this. Thanks!

1
  • Can you share your application repository? Commented Sep 7, 2014 at 7:39

1 Answer 1

1

You can do so by using <%= fomr_tag url: "/myCust" do %> method to create a form and wrap all the fields inside form tag. on submit button you will be redirect to /myCust method.

There you can get all the params in myCust method. You are using rails 4 then define all params under private method as it does. Store each of them. as you may want.

Sign up to request clarification or add additional context in comments.

3 Comments

I tried to do this but I must not understand; how does my custom method recognize which submit button is being pressed? If I press one submit button I want it to add numbers together, if I press another I want it to subtract them. in either case I want it to change the attribute on the controller object once its finished calculating.
I found this link but it doesn't work on mine :( I'm using submit_tag if that matters.
I figured out how to get it to work params[:commit] not :submit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.