Idiom for submit button?


#1

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

#2

Hello Hugh !

2005/11/22, Hugh S. removed_email_address@domain.invalid:

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/Helpers/FormTagHelper.html#M000407

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 !


#3

On 11/22/05, Hugh S. removed_email_address@domain.invalid wrote:

    Thank you,
    Hugh

<%= submit_tag ‘Go’ %>
http://rails.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html#M000407

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