# Buttons with different actions... for a single form

**URL:** <https://www.ruby-forum.com/t/buttons-with-different-actions-for-a-single-form/155793>\
**Category:** Rails\
**Created:** [December 16, 2008, 10:14pm UTC](https://www.ruby-forum.com/t/buttons-with-different-actions-for-a-single-form/155793 "2008-12-16T22:14:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@The\_N](https://www.ruby-forum.com/u/The_N)\
**Post date:** [December 16, 2008, 10:14pm UTC](https://www.ruby-forum.com/t/buttons-with-different-actions-for-a-single-form/155793/1 "2008-12-16T22:14:37Z")

</div>

Hello…

I have a form with 3 buttons, each with a different functionality  
concerning to forum user information. Once it’s shown in the form, you  
can:

- Modify your information
- Print your info (via Prawn)
- Delete the user

But I only have one form, and I need every button to do a different  
action. Can you please help me find something to make it work?

Greetings

The N.

---

<div class="post-metadata">

**Author:** ![The\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@The\_N](https://www.ruby-forum.com/u/The_N)\
**Post date:** [December 16, 2008, 10:53pm UTC](https://www.ruby-forum.com/t/buttons-with-different-actions-for-a-single-form/155793/2 "2008-12-16T22:53:37Z")

</div>

On Dec 16, 2008, at 4:13 PM, The N. wrote:

> But I only have one form, and I need every button to do a different  
> action. Can you please help me find something to make it work?
> 
> Greetings
> 
> The N.

The first one is clearly a submit button, but the other two could be  
link\_to\_function, button\_to\_function, link\_to\_remote, or  
button\_to\_remote. Those wouldn’t be ‘in’ the form. (Actually, the  
Delete the User could be a  
link\_to(‘Delete’, user\_path(@user), :method =\> :delete,  
:confirm =\> “Really delete #{@user.name}?\n(There is no  
undo!)”)  
or similar.)

You can get the name of the submit input activated, too, if you need  
to make a choice about what happens next. (I.e., “Complete Order” or  
“Change Shipping Address”)

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![The\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@The\_N](https://www.ruby-forum.com/u/The_N)\
**Post date:** [December 17, 2008, 3:40pm UTC](https://www.ruby-forum.com/t/buttons-with-different-actions-for-a-single-form/155793/3 "2008-12-17T15:40:51Z")

</div>

Can’t you just refetch user info from the database?

---

<div class="post-metadata">

**Author:** ![The\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@The\_N](https://www.ruby-forum.com/u/The_N)\
**Post date:** [December 17, 2008, 3:03pm UTC](https://www.ruby-forum.com/t/buttons-with-different-actions-for-a-single-form/155793/4 "2008-12-17T15:03:46Z")

</div>

I forgot to tell you it has to use elements of the form. The delete  
user could be separated from the form, but the Prawn (PDF) button  
functionality must have all the values of the form when something is  
modified. It has to be in the form is there a button\_to-like function  
inside the form?

Greetings…

The N.
