Drupal - How to set admin theme for a route?

You're looking for the _admin_route option:

aggregator.feed_add:
  path: '/aggregator/sources/add'
  defaults:
    _controller: '\Drupal\aggregator\Controller\AggregatorController::feedAdd'
    _title: 'Add feed'
  requirements:
    _permission: 'administer news feeds'
  options:
    _admin_route: TRUE

module.myroute:
  path: '/path/path2'
  defaults:
    _controller: 'Drupal\module\Controller\MyController::add'
    _title: 'Add element'
  options:
    _admin_route: 'TRUE'

You need to use ' ' around TRUE, if not, you will get 'InvalidArgumentException: Routing requirement for "options" must be a string'

Tags:

Routes

8