Profile picture for Admin

In most cases it is enough of functional of system_settings_form for saving settings and dont care 'bout submit ops. But what to do if it you need to add additional button to form?

To add a button and make it functional we need to add functoin to $form['#submit'] array.


Let's begin. Write standart form function.

Declare a variable $form

$form = system_settings_form($form);

After this, write down all your fields. At the end we added new button (Of course, new button can be added elsewhere after declare variable $form).

$form['actions']['custom_submit'] = array(

  '#type' => 'submit',

  '#value' => t('Custom submit'),


$form['#submit'][] = '_mymodule_custom_submit';

We added in array of submits our function. It will  fire after the system submit.

function _mymodule_custom_submit($form, $form_state) {
  switch ($form_state['clicked_button']['#value']) {
    case t('Custom submit'):
    // тут код

That's all. Now we have system form settings with built-in submit and our button.

Add new comment

The content of this field is kept private and will not be shown publicly.
  • No HTML tags allowed.
 d88   dP     dP  .d888b.  dP     dP  .d88888b  
88 88 88 Y8' `8P 88 88 88. "'
88 88 .8P d8bad8b 88 .8P `Y88888b.
88 88 d8' 88` `88 88 d8' `8b
88 88 .d8P 8b. .88 88 .d8P d8' .8P
d88P 888888' Y88888P 888888' Y88888P

Enter the code depicted in ASCII art style.