ldk2005
September 18, 2006, 7:33am
1
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
ldk2005
September 18, 2006, 8:15am
2
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.
ldk2005
September 18, 2006, 8:51am
3
It’s simply input :type => ‘button’
John W Higgins
[email protected]
ldk2005
September 19, 2006, 6:04pm
4
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
ldk2005
September 19, 2006, 7:58pm
5
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’ %>
ldk2005
September 19, 2006, 6:38pm
7
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