You are here

function fillpdf_test_form_fillpdf_settings_alter in FillPDF 5.0.x

Same name and namespace in other branches
  1. 8.4 tests/modules/fillpdf_test/fillpdf_test.module \fillpdf_test_form_fillpdf_settings_alter()

Implements hook_form_FORM_ID_alter().

File

tests/modules/fillpdf_test/fillpdf_test.module, line 14
Contains fillpdf_test.module.

Code

function fillpdf_test_form_fillpdf_settings_alter(array &$form, FormStateInterface $form_state, $form_id) {

  // Add a (redundant) radio for our test backend, not knowing that the backend
  // is autodetected. The label should be overwritten though.
  $form['backend']['#options']['test'] = 'Form-altered pass-through plugin for testing';

  // Add a test setting to the form.
  $form['example_setting'] = [
    '#type' => 'textfield',
    '#title' => 'Form-altered example setting',
    '#default_value' => \Drupal::config('fillpdf.settings')
      ->get('example_setting'),
    '#states' => [
      'visible' => [
        ':input[name="backend"]' => [
          'value' => 'test',
        ],
      ],
    ],
  ];

  // Add custom validate and submit functions.
  $form['#validate'][] = 'fillpdf_test_form_fillpdf_settings_validate';
  $form['#submit'][] = 'fillpdf_test_form_fillpdf_settings_submit';
}