function EntityTestHooks::formEntityTestFormAlter

Implements hook_form_BASE_FORM_ID_alter().

Attributes

#[Hook('form_entity_test_form_alter')]

File

core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php, line 243

Class

EntityTestHooks
Hook implementations for entity_test.

Namespace

Drupal\entity_test\Hook

Code

public function formEntityTestFormAlter(&$form) : void {
  switch (\Drupal::state()->get('entity_test.form.validate.test')) {
    case 'form-level':
      $form['#validate'][] = [
        Callbacks::class,
        'entityTestFormValidate',
      ];
      $form['#validate'][] = [
        Callbacks::class,
        'entityTestFormValidateCheck',
      ];
      break;

    case 'button-level':
      $form['actions']['submit']['#validate'][] = [
        Callbacks::class,
        'entityTestFormValidateCheck',
      ];
  }
}

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