You are here

function fillpdf_test_form_fillpdf_settings_validate in FillPDF 8.4

Same name and namespace in other branches
  1. 5.0.x tests/modules/fillpdf_test/fillpdf_test.module \fillpdf_test_form_fillpdf_settings_validate()

Custom validation for fillpdf_test_form_fillpdf_settings_alter().

1 string reference to 'fillpdf_test_form_fillpdf_settings_validate'
fillpdf_test_form_fillpdf_settings_alter in tests/modules/fillpdf_test/fillpdf_test.module
Implements hook_form_FORM_ID_alter().

File

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

Code

function fillpdf_test_form_fillpdf_settings_validate($form, FormStateInterface &$form_state) {
  if ($form_state
    ->getValue('backend') == 'test') {

    // Only validate if a value is set.
    $value = $form_state
      ->getValue('example_setting');
    if (!empty($value) && strlen($value) < 2) {
      $form_state
        ->setErrorByName('example_setting', t('Not a valid value.'));
    }
  }
}