By nicxvan on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.3.x
Introduced in version:
11.3.0
Issue links:
Description:
Previously forms that call \Drupal\views_ui\ViewsUI::getStandardButtons() could have a custom cancel submit handler automatically applied if it was named $form_id . '_cancel'. If this function did not exist the cancel button would use ViewUI::standardCancel() instead.
These magically named cancel functions have been deprecated. Specify a submit handler in a class method instead.
Before:
<?php
function my_form_id_cancel($form, FormStateInterface $form_state) {
// Custom handler.
}
class MyForm extends ViewsFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$view->getStandardButtons($form, $form_state, 'my_form_id');
}
}
?>
After:
<?php
class MyForm extends ViewsFormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$view->getStandardButtons($form, $form_state, 'my_form_id');
$form['actions']['cancel']['#submit'] = [[$this, 'cancelSubmit']],
}
public function cancelSubmit($form, FormStateInterface $form_state) {
// Custom handler.
}
}
?>
Impacts:
Module developers
Themers