class ViewsTestDataErrorForm

Same name and namespace in other branches
  1. 11.x core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php \Drupal\views_test_data\Form\ViewsTestDataErrorForm
  2. 10 core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php \Drupal\views_test_data\Form\ViewsTestDataErrorForm
  3. 8.9.x core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php \Drupal\views_test_data\Form\ViewsTestDataErrorForm
  4. main core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php \Drupal\views_test_data\Form\ViewsTestDataErrorForm

Implements a test form that has a validation error.

Hierarchy

Expanded class hierarchy of ViewsTestDataErrorForm

File

core/modules/views/tests/modules/views_test_data/src/Form/ViewsTestDataErrorForm.php, line 11

Namespace

Drupal\views_test_data\Form
View source
class ViewsTestDataErrorForm implements FormInterface {
  
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'views_test_data_error_form';
  }
  
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form['text'] = [
      '#type' => 'textfield',
    ];
    $form['submit'] = [
      '#type' => 'submit',
      '#value' => t('Submit'),
    ];
    return $form;
  }
  
  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $form_state->setErrorByName('text', t('Form validation error'));
  }
  
  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
  }

}

Members


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