You are here

function readonlymode_check_form_validate in Read only mode 8

Same name and namespace in other branches
  1. 6 readonlymode.module \readonlymode_check_form_validate()
  2. 7 readonlymode.module \readonlymode_check_form_validate()

Validation handler for all form submissions.

Checks whether the form submission is occurring while Read Only Mode is enabled.

1 string reference to 'readonlymode_check_form_validate'
readonlymode_form_alter in ./readonlymode.module
Implements hook_form_alter().

File

./readonlymode.module, line 180
Read Only Mode provides an alternative to the built in 'Maintenance Mode' in Drupal. Instead of displaying a static text file to users while the site is in maintenance mode, Read Only Mode will allow access (reading) of existing content…

Code

function readonlymode_check_form_validate(array &$form, FormStateInterface $form_state) {

  // Check for Read Only Mode, whether we are allowed this form,.
  if (!_readonlymode_form_check($form, $form['form_id']['#value'], TRUE)) {
    $form_state
      ->setErrorByName('submit', \Drupal::token()
      ->replace(\Drupal::config('readonlymode.settings')
      ->get('messages.not_saved')));
  }
}