Problem/Motivation

When a form has multiple submit buttons, each one with a different callback sometimes the wrong callback actions is called

Steps to reproduce

Create a custom form with multiple callbacks and when it submits ignore the callback value and submit always to the first one, callback_a

<?php
$form['submit_calback_a']['1'] = array(
      '#type' => 'submit',
      '#submit' => array(
        'calback_a',
      ),
      '#value' => 'lorem',
      '#attributes' => array(
        'class' => array('btn-link'),
        'title' => t('calback_a'),
    
      ),
      '#name' => 'submit-callback_a',
    );

 $form['submit_calback_b']['1'] = array(
      '#type' => 'submit',
      '#submit' => array(
        'calback_b',
      ),
      '#value' => 'lorem',
      '#attributes' => array(
        'class' => array('btn-link'),
        'title' => t('calback_b'),
    
      ),
      '#name' => 'submit-callback_b',
    );

   $form['submit_calback_c']['1'] = array(
      '#type' => 'submit',
      '#submit' => array(
        'calback_c',
      ),
      '#value' => 'lorem',
      '#attributes' => array(
        'class' => array('btn-link'),
        'title' => t('calback_c'),
    
      ),
      '#name' => 'submit-callback_c',
    );
?>

Issue fork drupal-3376628

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pjflopes created an issue. See original summary.

jlopes23’s picture

Issue summary: View changes

vaibhav340 made their first commit to this issue’s fork.

vaibhav340’s picture

Sorry Wrong comment.. Unable to delete it

poker10’s picture

Thanks for reporting this @jlopes23.

I have tested this manually on clean Drupal 7.98 install with a simple form (code you provided) and it seems like the correct submit handlers are called. Can you please test this with a simple custom form containing only the code you provided, if it is still a problem?

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.