n How to add a specific css class to webforms form tag in Drupal 8 | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh

Code snippet that can be used to add a specific css class to webforms/forms form tag in Drupal 8.

 * @param $form
 * @param $form_state
 * @param $form_id
function mymodule_form_alter(&$form, &$form_state, $form_id)
  if ($form_id == 'webform_submission_contact_add_form') {
    // add class to tag <form> 
    $form['#attributes']['class'][] = 'my-custom-class';

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts


Page Facebook