You are here

function readonlymode_settings_form_validate in Read only mode 8

Settings form validate handler.

See readonlymode_form_system_site_maintenance_mode_alter().

1 string reference to 'readonlymode_settings_form_validate'
readonlymode_form_system_site_maintenance_mode_alter in ./readonlymode.module
Implements hook_form_FORM_ID_alter().

File

./readonlymode.module, line 102
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_settings_form_validate(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  if ($path = $values['url']) {
    $path_validator = \Drupal::pathValidator();
    if (!$path_validator
      ->isValid($form_state
      ->getValue('url'))) {
      $form_state
        ->setErrorByName('url', t('The path %link_path is either invalid or you do not have access to it.', [
        '%link_path' => $path,
      ]));
    }
  }
}