function TestNodeFormOverride::submitForm

Same name and namespace in other branches
  1. 9 core/modules/media_library/tests/modules/media_library_test/src/Form/TestNodeFormOverride.php \Drupal\media_library_test\Form\TestNodeFormOverride::submitForm()
  2. 8.9.x core/modules/media_library/tests/modules/media_library_test/src/Form/TestNodeFormOverride.php \Drupal\media_library_test\Form\TestNodeFormOverride::submitForm()
  3. 10 core/modules/media_library/tests/modules/media_library_test/src/Form/TestNodeFormOverride.php \Drupal\media_library_test\Form\TestNodeFormOverride::submitForm()

Overrides ContentEntityForm::submitForm

File

core/modules/media_library/tests/modules/media_library_test/src/Form/TestNodeFormOverride.php, line 16

Class

TestNodeFormOverride
Override NodeForm to test media library form submission semantics.

Namespace

Drupal\media_library_test\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $triggering_element = $form_state->getTriggeringElement();
    if (in_array('open_button', $triggering_element['#parents'], TRUE)) {
        throw new \Exception('The media library widget open_button element should not trigger form submit.');
    }
    parent::submitForm($form, $form_state);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.