Skip to content

Instantly share code, notes, and snippets.

@woutersf
Last active December 30, 2016 08:10
Show Gist options
  • Save woutersf/68df682430cd27021285dc60d38680d0 to your computer and use it in GitHub Desktop.
Save woutersf/68df682430cd27021285dc60d38680d0 to your computer and use it in GitHub Desktop.
<?php
//use...
class MySettingsForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
//The form
//..
//The custom button:
$form['index']['recreate_index'] = array(
'#type' => 'submit',
'#value' => t('recreate index'),
'#submit' => array('::submitRecreateForm'), //This is where the magic happens!
);
}
return parent::buildForm($form, $form_state);
}
//This is called on click of the (not submit) button.
public function submitRecreateForm(array &$form, FormStateInterface $form_state){
die('apart button submithandler');
}
//This is called on click of the submit button.
public function submitForm(array &$form, FormStateInterface $form_state) {
die('general submithandler triggered');
//parent::submitForm($form, $form_state);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment