Skip to main content
Category:

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

Search

Page Facebook