Get Webform Category Name in Preprocess I am trying to get the Category name (from the General form settings) for webforms in a preprocess function, ultimately to add as a class to the webform wrapper.

MYMODULE.module:

function MYMODULE_preprocess_webform(&amp;$variables) {
  kint($variables);
}


Right now I don't see a "category" value in the array structure.

How do you get this value in preprocess? Maybe I need a different hook?
Not quite clear on the question actually. So you're saying you want to get the settings value from webform element "Category" list before it's submitted and set it as your form wrapper?

Here's some tip I recently learned, hope it helps.


// get all webform submissions id from my_webform
$query = \Drupal::entityQuery('webform_submission')-&gt;condition('webform_id', 'my_webform');
$result = $query-&gt;execute();

// load all submission data from webform submission storage
$webformStorage = \Drupal::entityTypeManager()-&gt;getStorage('webform_submission');
$submissions = $webformStorage-&gt;loadMultiple($result);



If you want to get the submission values form webform, then you can use WebformSubmission class. 

If your want to get the element settings value that user sees from your category list, then you'll need Webform class to load the options array from the webform element.

use Drupal\webform\Entity\WebformSubmission;
use Drupal\webform\Entity\Webform;

// get sid from your preprocess or elsewhere
$webform_submission = WebformSubmission::load($sid);

// This will return the data array of submitted values from sid given.
$data = $webform_submission-&gt;getData();

// Load webform with bundle type id, normally it's your webform machine name
$webform = Webform::load($sid-&gt;bundle());

// Get element definition in webform element
$select_list_element = $webform-&gt;getElement('key_name');

// for options in Select list. this may vary depending on what element type you're using
$select_list = $select_list_element['#options'];