Use custom form submit function inside class


In my controller I am loading a form and including one custom submit handler. However the submit function is not called. I think that it’s either not found or not accessible as it is inside the controller class:

class MyController extends ControllerBase {


  public function myProfile() {
    $user = User::load($this->currentUser->id());
    $form = $this->entityFormBuilder()->getForm($user);

    $form['actions']['submit']['#submit'][] = '::_custom_submit_form';

  protected function _custom_submit_form(array &$form, DrupalCoreFormFormStateInterface $form_state) { 


If I use hook_form_alter it works, but I don’t want to use a hook as I can directly manipulate the form.

قالب وردپرس