Forum: Ruby on Rails Idiom for submit button?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
457cf540784a12ba2f30e06565a2c189?d=identicon&s=25 hgs (Guest)
on 2005-11-22 20:35
(Received via mailing list)
What is the rails idiom for submit buttons on forms?
All other field types have helpers, but button_to creates its
own form, so should not be used.  I've looked in "Agile Web Dev. with
Rails" but can't see what I should do instead.

Is this "difficult" because it runs counter to AJAX type forms?

And, related, is there a way to ensure that hitting return in a
field does not submit the form?

        Thank you,
        Hugh
3dd4b52a0946bd698b1d1635a46ea3a3?d=identicon&s=25 francois.beausoleil (Guest)
on 2005-11-22 20:39
(Received via mailing list)
Hello Hugh !

2005/11/22, Hugh Sasse <hgs@dmu.ac.uk>:
> What is the rails idiom for submit buttons on forms?
> All other field types have helpers, but button_to creates its
> own form, so should not be used.  I've looked in "Agile Web Dev. with
> Rails" but can't see what I should do instead.

What you're looking for is "submit_tag":  http://rubyurl.com/ULX
http://api.rubyonrails.com/classes/ActionView/Help...

> And, related, is there a way to ensure that hitting return in a
> field does not submit the form?

Nope, this is a browser feature.  The best you can do is attach a
JavaScript event to your fields that prevents Enter from being a
submit trigger.  I wonder why you'd want to do that, though, as I find
this a very important feature for me.

Hope that helps !
821395fe70906c8290df7f18ac4ac6cf?d=identicon&s=25 technoweenie (Guest)
on 2005-11-22 20:43
(Received via mailing list)
On 11/22/05, Hugh Sasse <hgs@dmu.ac.uk> wrote:
>         Thank you,
>         Hugh

<%= submit_tag 'Go' %>
http://rails.rubyonrails.com/classes/ActionView/He...

As for hitting return to submit a form...  i believe that's more a
function of your browser that does that.

--
rick
http://techno-weenie.net
This topic is locked and can not be replied to.