You are here

function _better_revisions_validate in Better Revisions 8

Same name and namespace in other branches
  1. 7 better_revisions.module \_better_revisions_validate()

Custom validate function.

1 string reference to '_better_revisions_validate'
better_revisions_form_alter in ./better_revisions.module
Implements hook_form_alter().

File

./better_revisions.module, line 96
Main enhanced revisions module file.

Code

function _better_revisions_validate($form, &$form_state) {
  $config = \Drupal::config('better_revisions.settings');
  if (!$form_state
    ->getValue('revision')) {
    return;
  }
  $req = $config
    ->get('br_require');
  $area = $config
    ->get('br_add_txt') == 2;
  if ($req) {
    if (!$form_state
      ->getValue('revision_log')) {
      $msg = $config
        ->get('br_list_title') . ' is required';
      $form_state
        ->setErrorByName('revision_log', t($msg));
    }
  }
  if ($area) {
    if (!$form_state
      ->getValue('revision_log_extra')) {
      $msg = $config
        ->get('br_area_title') . ' is required';
      $form_state
        ->setErrorByName('revision_log_extra', t($msg));
    }
  }
}