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.
  .88888.    d88    88888888b  .d888b.   a88888b. 
d8' `8b 88 88 Y8' `8P d8' `88
88 88 88 a88aaaa d8bad8b 88
88 db 88 88 88 88` `88 88
Y8. Y88P 88 88 8b. .88 Y8. .88
`8888PY8b d88P dP Y88888P Y88888P'

Enter the code depicted in ASCII art style.