Adding a button to a form

I’ve looked at the API, and the only ‘button’ reference I found was for
submit. How would I add another button to a form? I tried:

button_tag ‘Do Something’, :action => ‘do_something’

But that gave me an error.

Any help would be appreciated.


Best Regards,
-Larry
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson

As far as I know, the form can only submit to one place, but you can
put logic in the action it submits to that determines which button was
clicked. I have a form that does this and the logic basically goes like
this…

case params[“commit”]
when “Do This”
some code to do something
when “Do That”
some code to do something else
end

The “commit” might be able to change to :commit. (Can’t remember.) The
“Do This” and “Do That” are the values of the submit buttons.

It’s simply input :type => ‘button’

John W Higgins
[email protected]

John,
It sounds so simple, yet I can’t seem to get it right. When I enter
this
line into my view:

   <%= input :type => 'button' %>

I get this error:

wrong number of arguments (1 for 2)

So, I changed it to :

 <%= input 'Do Something', :type => 'button' %>

which returns a different error:

`@Do Something’ is not allowed as an instance variable name

What am I missing, here.
-Larry

On 9/17/06, John H. [email protected] wrote:

submit. How would I add another button to a form? I tried:
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson


Best Regards,
-Larry
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson

Michael C. wrote:

I get this error:
`@Do Something’ is not allowed as an instance variable name

John W Higgins

“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson


More software projects have gone awry for lack of calendar time than
for all other causes combined. – Fred Brooks

A neat trick for this that I picked up somewhere…

give your custom button a :name attribute.

<%= submit ‘cancel’, :name=>:cancel %>

Then on submission, look for params[:cancel]. If it’s there, that
button was pressed.

_Kevin

Try this:
<%= submit_tag “Name”, :type => ‘button’ %>

api.rubyonrails.com has an entry for the input tag.

On 9/19/06, Larry K. [email protected] wrote:

-Larry


Best Regards,
-Larry
“Work, work, work…there is no satisfactory alternative.”
— E.Taft Benson


More software projects have gone awry for lack of calendar time than
for all other causes combined. – Fred Brooks