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 7937995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:40:49+00:00 2026-06-03T22:40:49+00:00

A question exactly like this was asked last year, but this question was for

  • 0

A question exactly like this was asked last year, but this question was for Drupal 6, I’m wondering if there has been a change for Drupal 7.

Can I make the second or later button in a Drupal form the default button?

In my form, I have about four submit button form elements. Three of the four have a specified submit function and the other one uses the default hook_form_submit() function to handle it’s submission.

So this is what three buttons almost look like:

$form['reset'] = array(
   '#type' => 'submit',
   '#value' => t('Reset Values'),
   '#submit' => array('_phonebook_reset_config'),
);

This is what the main button looks like:

$form['submit'] = array(
   '#type' => 'submit',
   '#value' => t('Update'),
);

This is the order in which the buttons are created in the form: (Button_1, Button_2, Main_Button, Button_4).

Right now if I press enter on the form, Button_1 gets executed. I want the main button to be the default button, so that when the user press enter, that main button is submitted not Button_1.

In the post mentioned above, one of the answers was to use weight. I tried using weight, but all that did was change the way the button was ordered on the screen. Yes this did allow the Main_Button, to be submitted, but then I needed that button in its original location.

  • 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-06-03T22:40:51+00:00Added an answer on June 3, 2026 at 10:40 pm

    This can’t be done with just HTML. (So there’s nothing Form API can do) As there is no standard and no html properties to handle a default submit in a multiple submit form. You should use CSS but if you don’t wanna restyle you can use jQuery. Good luck!

     //Not tested
      $("#target").keypress(function(event) {
        if ( event.which == 13 ) {
           event.preventDefault();
           $('correctSubmit').submit();
         }
      });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry If something like this has already been asked, but I can't find exactly
So, if this question has been asked before, I'm sorry. I'm not exactly sure
Hey a similar question has been asked before, but none that answers mine exactly.
This has been asked before (question no. 308581) , but that particular question and
Variations of this question have been asked before, but it seems like the issue
I feel that this question has been asked 10^78 times, but for some reason,
I don't know if this question has been asked before, but I'll go through
Various incarnations of this question have been asked here before, but I thought I'd
Sorry I know similar question have been asked many times before but like most
I'm a python newbie so I apologize in advance if this question has been

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.