I've made a custom module, and I would like to load the library only on the Webform submission pages. The url looks like this:

/admin/structure/webform/manage/form_name/submission/{{submission number}}

So far my module_name.module file looks like this:

function module_name_preprocess_page(&$vars){

 // get current path
  $current_path = Drupal::request()->getRequestUri();

  //maybe I need to check if string exists in path?

  if ( //not sure how to check it here ) {
    // attach our library
    $vars['#attached']['library'][] = 'module_name/library';


I also need to work regardless of the form name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.