Change Theme To Admin For Custom Module Page

I’ll forgo the PROBLEM/SOLUTION in this one since it’s so quick.

I wanted to make the pages (forms) of a custom module I was creating use the admin theme instead of the public facing theme. Turns out it was really easy.

In the .routing.yml file, add the following:

  options:
    _admin_route: TRUE

So a cleaned-up example of the yml looks like this:

whatever_your_form_is.form:
  path: '/whatever/your/path/is'
  defaults:
    _form: '\Drupal\module_name\Form\WhateverYourFormIs'
    _title: 'Page/Form Title'
  requirements:
    _role: 'authenticated'
  options:
    _admin_route: TRUE

Need this in my arsenal.


Deprecated: Function get_currentuserinfo is deprecated since version 4.5.0! Use wp_get_current_user() instead. in /home/niles38/longlivethemonkey.com/syntaxnotes/wp-includes/functions.php on line 6031

Leave a Reply

Your email address will not be published. Required fields are marked *