navigation404.module in 404 Navigation 8
Same filename and directory in other branches
main module file.
File
navigation404.moduleView source
<?php
/**
* @file main module file.
*/
define('NAVIGATION404_PAGE', 'navigation404');
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_alter().
*/
function navigation404_form_system_site_information_settings_alter(&$form, FormStateInterface $form_state) {
// Since we don't care what site_404 is set to, let the user set it if they want.
if ($form['error_page']['site_404']['#default_value'] == NAVIGATION404_PAGE) {
$form['error_page']['site_404']['#default_value'] = '';
}
// Insert our submit handler first.
array_unshift($form['#submit'], 'navigation404_site_404_submit');
}
/**
* Submit callback for system_site_information_settings form.
*/
function navigation404_site_404_submit($form, FormStateInterface $form_state) {
// Make sure site_404 is not empty.
$site_404 = $form_state
->getValue('site_404');
if (empty($site_404)) {
$form_state
->setValue('site_404', NAVIGATION404_PAGE);
}
}
Functions
Name | Description |
---|---|
navigation404_form_system_site_information_settings_alter | Implements hook_form_alter(). |
navigation404_site_404_submit | Submit callback for system_site_information_settings form. |
Constants
Name | Description |
---|---|
NAVIGATION404_PAGE | @file main module file. |