Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6157949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:52:16+00:00 2026-05-23T20:52:16+00:00

Can I have a button in side the form, but do not have the

  • 0

Can I have a button in side the form, but do not have the type=submit?

I am doing something special. I have a form,

<%= form_for(@user) do |f| %>

and this form will be rendered based on a value in a session.

In side the form, I have f.submit already and I want to have another button, cancel button, to invoke a method from controller to change the session value if user want to cancel the input.

But if I use button_to, the type of the button will be “submit”, when I click on the button, it will submit the whole form. If some of the value are not valid, it will complain. It does not work as the “cancel” button that I expected.

So can I have a button that does not submit the form?

I tried to use submit_tag, but the buttom dosn`t work for me…

<%= submit_tag 'Cancel Edit', :type => 'button', :controller => 'my_account', :action=>'cancel_edit' %>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:52:17+00:00Added an answer on May 23, 2026 at 8:52 pm

    The button_to helper actually generates a whole form:

    Generates a form containing a single button that submits to the URL created by the set of options.

    So that’s definitely not what you want. I think you just want to generate a simple <input type="button"> element in your HTML. However, there is no button_tag in FormTagHelper but there is a submit_tag that you can hand a :type option to and that will:

    Any other key creates standard HTML options for the tag.

    So try this:

    submit_tag 'Pancakes', :type => 'button'
    

    where “Pancakes” would be your real label.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a radio button on my Windows Form. How can I determine if
I have a javascript backed 'print' button on my webpage where the user can
I have a ASP.NET page with an asp:button that is not visible. I can't
I have read that I can suppress this noise by defining a form accept
I need a button-like control that can have a Checked property, so that when
I have GridView which I can select a row. I then have a button
want to have a Hyperlink-Button in a gridView in which I can display a
I have inherited a c# class 'Button' (which I can't change) which clashes with
Can I disable the minimize button in JFrame? I have already tried setUndecorated() and
I have a jqGrid on a page and users can click a button to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.